From da326aedff97288eb8b4f3544c55bc55b0816c09 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Tue, 19 Jul 2022 10:47:18 -0400 Subject: [PATCH] report: Correct type annotation allowing unauth access. `report/error` is a path where we allow anonymous user access. This has to be correctly denoted in the type annotation of the user argument of the view function. Signed-off-by: Zixuan James Li --- zerver/views/report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/views/report.py b/zerver/views/report.py index b77d00a4d3..bfbf6b352e 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -119,7 +119,7 @@ def report_unnarrow_times( @has_request_variables def report_error( request: HttpRequest, - user_profile: UserProfile, + maybe_user_profile: Union[AnonymousUser, UserProfile], message: str = REQ(), stacktrace: str = REQ(), ui_message: bool = REQ(json_validator=check_bool), @@ -155,9 +155,9 @@ def report_error( if more_info.get("draft_content"): more_info["draft_content"] = privacy_clean_markdown(more_info["draft_content"]) - if user_profile.is_authenticated: - email = user_profile.delivery_email - full_name = user_profile.full_name + if maybe_user_profile.is_authenticated: + email = maybe_user_profile.delivery_email + full_name = maybe_user_profile.full_name else: email = "unauthenticated@example.com" full_name = "Anonymous User"