From 6930c844259f4f19935407d959194d0197aa0d52 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 24 Jun 2021 13:01:41 +0200 Subject: [PATCH] events: only create SYSTEM_EXCEPTION event when error would've been sent to sentry Signed-off-by: Jens Langhammer --- authentik/events/middleware.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/authentik/events/middleware.py b/authentik/events/middleware.py index 684121171..1543fb8ef 100644 --- a/authentik/events/middleware.py +++ b/authentik/events/middleware.py @@ -13,6 +13,7 @@ from authentik.core.models import User from authentik.events.models import Event, EventAction, Notification from authentik.events.signals import EventNewThread from authentik.events.utils import model_to_dict +from authentik.lib.sentry import before_send from authentik.lib.utils.errors import exception_to_string @@ -62,12 +63,13 @@ class AuditMiddleware: if settings.DEBUG: return - thread = EventNewThread( - EventAction.SYSTEM_EXCEPTION, - request, - message=exception_to_string(exception), - ) - thread.run() + if before_send({}, {"exc_info": (None, exception, None)}) is not None: + thread = EventNewThread( + EventAction.SYSTEM_EXCEPTION, + request, + message=exception_to_string(exception), + ) + thread.run() @staticmethod # pylint: disable=unused-argument