From 6e442902e183779931bb6a8a36c9d03c011fefd4 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 7 Mar 2017 21:08:42 -0800 Subject: [PATCH] AdminZulipHandler: Don't print extra traceback for logged-out users. This is not an interesting condition worth highlighting for sysadmins. Fixes #3963. --- zerver/logging_handlers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zerver/logging_handlers.py b/zerver/logging_handlers.py index 6bd26472cb..6b8a36e3f5 100644 --- a/zerver/logging_handlers.py +++ b/zerver/logging_handlers.py @@ -38,12 +38,17 @@ class AdminZulipHandler(logging.Handler): stack_trace = None try: + from django.contrib.auth.models import AnonymousUser user_profile = request.user - user_full_name = user_profile.full_name - user_email = user_profile.email + if isinstance(user_profile, AnonymousUser): + user_full_name = None + user_email = None + else: + user_full_name = user_profile.full_name + user_email = user_profile.email except Exception: + # Unexpected exceptions here should be handled gracefully traceback.print_exc() - # Error was triggered by an anonymous user. user_full_name = None user_email = None