Skip to content

Commit

Permalink
sentry: Fix type error in add_context.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk authored and timabbott committed Mar 21, 2024
1 parent eb622ba commit 71e1b3c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zproject/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 71e1b3c

Please sign in to comment.