From 2c3aa7b2dc2b9fb6e57ca8b064c0359162cd45b2 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 14 Nov 2024 08:23:38 +0200 Subject: [PATCH] Improve actor data extraction logic in Bitbucket app server --- pr_agent/servers/bitbucket_app.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pr_agent/servers/bitbucket_app.py b/pr_agent/servers/bitbucket_app.py index ab810f5a8..98df69a64 100644 --- a/pr_agent/servers/bitbucket_app.py +++ b/pr_agent/servers/bitbucket_app.py @@ -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