mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
Add error handling for missing username fields in Bitbucket webhook handler and update log context
This commit is contained in:
@ -108,13 +108,18 @@ async def handle_github_webhooks(background_tasks: BackgroundTasks, request: Req
|
|||||||
return "OK"
|
return "OK"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
get_logger().error("Failed to get actor type, check previous logs, this shouldn't happen.")
|
get_logger().error("Failed to get actor type, check previous logs, this shouldn't happen.")
|
||||||
|
|
||||||
|
# Get the username of the sender
|
||||||
try:
|
try:
|
||||||
owner = data["data"]["repository"]["owner"]["username"]
|
username = data["data"]["actor"]["username"]
|
||||||
except Exception as e:
|
except KeyError:
|
||||||
get_logger().error(f"Failed to get owner, will continue: {e}")
|
try:
|
||||||
owner = "unknown"
|
username = data["data"]["actor"]["display_name"]
|
||||||
|
except KeyError:
|
||||||
|
username = data["data"]["actor"]["nickname"]
|
||||||
|
log_context["sender"] = username
|
||||||
|
|
||||||
sender_id = data["data"]["actor"]["account_id"]
|
sender_id = data["data"]["actor"]["account_id"]
|
||||||
log_context["sender"] = owner
|
|
||||||
log_context["sender_id"] = sender_id
|
log_context["sender_id"] = sender_id
|
||||||
jwt_parts = input_jwt.split(".")
|
jwt_parts = input_jwt.split(".")
|
||||||
claim_part = jwt_parts[1]
|
claim_part = jwt_parts[1]
|
||||||
|
Reference in New Issue
Block a user