Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

sentry: Fix type error in add_context.

Anders Kaseorg71e1b3c91bb5
diff --git a/zproject/sentry.py b/zproject/sentry.py
index 7d184b43067..8d004d4539f 100644
--- a/zproject/sentry.py
+++ b/zproject/sentry.py
@@ -32,8 +32,9 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
# https://docs.sentry.io/platforms/python/guides/django/enriching-error-data/additional-data/identify-user/
event.setdefault("tags", {})
user_info = event.get("user", {})
- if user_info.get("id"):
- user_profile = get_user_profile_by_id(user_info["id"])
+ user_id = user_info.get("id")
+ if isinstance(user_id, str):
+ user_profile = get_user_profile_by_id(int(user_id))
event["tags"]["realm"] = user_info["realm"] = user_profile.realm.string_id or "root"
with override_language(settings.LANGUAGE_CODE):
# str() to force the lazy-translation to apply now,