From b034d16c23beb59c4d9ef222b0844b0e8f7ea0b0 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 19 Aug 2024 14:18:45 +0300 Subject: [PATCH 1/2] Add validation checks for 'latest_comment' and 'pr_url' in GitHub polling server --- pr_agent/servers/github_polling.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pr_agent/servers/github_polling.py b/pr_agent/servers/github_polling.py index 627390c01..c7bb5bff5 100644 --- a/pr_agent/servers/github_polling.py +++ b/pr_agent/servers/github_polling.py @@ -80,6 +80,8 @@ async def polling_loop(): if 'subject' in notification and notification['subject']['type'] == 'PullRequest': pr_url = notification['subject']['url'] latest_comment = notification['subject']['latest_comment_url'] + if not isinstance(latest_comment, str) or not latest_comment or not pr_url: + continue async with session.get(latest_comment, headers=headers) as comment_response: if comment_response.status == 200: comment = await comment_response.json() From b9d096187ad59c3fcae17eef37eab0452eed0e94 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 25 Aug 2024 07:21:40 +0300 Subject: [PATCH 2/2] fix: skip processing comments without a body in GitHub polling server --- pr_agent/servers/github_polling.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pr_agent/servers/github_polling.py b/pr_agent/servers/github_polling.py index 52c00552d..64f4dea9d 100644 --- a/pr_agent/servers/github_polling.py +++ b/pr_agent/servers/github_polling.py @@ -93,7 +93,9 @@ async def polling_loop(): if 'user' in comment and 'login' in comment['user']: if comment['user']['login'] == user_id: continue - comment_body = comment['body'] if 'body' in comment else '' + comment_body = comment.get('body', '') + if not comment_body: + continue commenter_github_user = comment['user']['login'] \ if 'user' in comment else '' get_logger().info(f"Polling, pr_url: {pr_url}",