From 6c3b7c8d3ecfec89e12ceefcd720b02071825a4b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 6 May 2021 20:13:04 +0200 Subject: [PATCH] events: handle error when notifications are triggered and no users exist Signed-off-by: Jens Langhammer --- authentik/events/tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/events/tasks.py b/authentik/events/tasks.py index 994353d2d..6ce94fa90 100644 --- a/authentik/events/tasks.py +++ b/authentik/events/tasks.py @@ -61,7 +61,13 @@ def event_trigger_handler(event_uuid: str, trigger_name: str): return LOGGER.debug("e(trigger): checking if trigger applies", trigger=trigger) - user = User.objects.filter(pk=event.user.get("pk")).first() or get_anonymous_user() + try: + user = ( + User.objects.filter(pk=event.user.get("pk")).first() or get_anonymous_user() + ) + except User.DoesNotExist: + LOGGER.warning("e(trigger): failed to get user", trigger=trigger) + return policy_engine = PolicyEngine(trigger, user) policy_engine.mode = PolicyEngineMode.MODE_ANY policy_engine.empty_result = False