From 4c7f54cf7205417a926a75d54aa4d769d05185af Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 8 Jul 2016 12:54:42 -0400 Subject: [PATCH] Fix an activity stream associate with deleted obj In some scenarios the activity stream associate could be invoked where obj2 doesn't exist... the .get() will fail and tank the caller preventing the save. This guards that and blocks the activity stream event, saving the save (whew!) --- awx/main/signals.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awx/main/signals.py b/awx/main/signals.py index 6138ee17bd..1c57fea8ae 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -410,7 +410,10 @@ def activity_stream_associate(sender, instance, **kwargs): for entity_acted in kwargs['pk_set']: obj2 = kwargs['model'] obj2_id = entity_acted - obj2_actual = obj2.objects.get(id=obj2_id) + obj2_actual = obj2.objects.filter(id=obj2_id) + if not obj2_actual.exists(): + continue + obj2_actual = obj2_actual[0] if isinstance(obj2_actual, Role) and obj2_actual.content_object is not None: obj2_actual = obj2_actual.content_object object2 = camelcase_to_underscore(obj2_actual.__class__.__name__)