From 80224b791d29e2155fc6d90f2a6752ae9575592e Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 12 Jul 2017 16:38:05 -0400 Subject: [PATCH] avoid a race condition in recording deletions in the activity stream 1. You delete something. 2. A signal is generated to record an activity stream deletion. 3. The process of deleting that activity stream deletion attempts to look up a related field which has been deleted (in the meantime) via a cascade. see: #6721 see: #7022 --- awx/main/utils/common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index 473683a668..392ebaa961 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -21,6 +21,7 @@ import tempfile from decorator import decorator # Django +from django.core.exceptions import ObjectDoesNotExist from django.utils.translation import ugettext_lazy as _ from django.db.models.fields.related import ForeignObjectRel, ManyToManyField @@ -354,7 +355,10 @@ def model_to_dict(obj, serializer_mapping=None): for field in obj._meta.fields: if field.name not in allowed_fields: continue - attr_d[field.name] = _convert_model_field_for_display(obj, field.name, password_fields=password_fields) + try: + attr_d[field.name] = _convert_model_field_for_display(obj, field.name, password_fields=password_fields) + except ObjectDoesNotExist: + logger.warn(_('%s no longer exists for %s') % (field.name, obj)) return attr_d