From 5677ae85325ab6e1304767ce6888e55a356674eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 20 Oct 2016 17:43:51 +0200 Subject: [PATCH] Prevent errors when notification is linked to non-existing node --- pillar/api/activities.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pillar/api/activities.py b/pillar/api/activities.py index dad3b2cc..efc7ffd7 100644 --- a/pillar/api/activities.py +++ b/pillar/api/activities.py @@ -17,6 +17,11 @@ def notification_parse(notification): if activity is None or activity['object_type'] != 'node': return node = nodes_collection.find_one({'_id': activity['object']}) + if not node: + # This can happen when a notification is generated and then the + # node is deleted. + return + # Initial support only for node_type comments if node['node_type'] != 'comment': return