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