Skip to content

Commit

Permalink
Improve actor data extraction logic in Bitbucket app server
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Nov 14, 2024
1 parent c934523 commit 2c3aa7b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pr_agent/servers/bitbucket_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ async def inner():
return "OK"

# Get the username of the sender
try:
username = data["data"]["actor"]["username"]
except KeyError:
actor = data.get("data", {}).get("actor", {})
if actor:
try:
username = data["data"]["actor"]["display_name"]
username = actor["username"]
except KeyError:
username = data["data"]["actor"]["nickname"]
log_context["sender"] = username
try:
username = actor["display_name"]
except KeyError:
username = actor["nickname"]
log_context["sender"] = username

sender_id = data["data"]["actor"]["account_id"]
log_context["sender_id"] = sender_id
Expand Down

0 comments on commit 2c3aa7b

Please sign in to comment.