From c8d369ee61fa571f9f513d678b6fd8e28ebebe9f Mon Sep 17 00:00:00 2001 From: Ori Kotek Date: Thu, 6 Jul 2023 20:04:32 +0300 Subject: [PATCH] Protect against no notifications received --- pr_agent/servers/github_polling.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pr_agent/servers/github_polling.py b/pr_agent/servers/github_polling.py index 90aac6bf..45d2942a 100644 --- a/pr_agent/servers/github_polling.py +++ b/pr_agent/servers/github_polling.py @@ -58,8 +58,6 @@ async def polling_loop(): if not notifications: continue for notification in notifications: - if 'id' in notification and notification['id'] in handled_ids: - continue handled_ids.add(notification['id']) if 'reason' in notification and notification['reason'] == 'mention': if 'subject' in notification and notification['subject']['type'] == 'PullRequest': @@ -68,6 +66,11 @@ async def polling_loop(): async with session.get(latest_comment, headers=headers) as comment_response: if comment_response.status == 200: comment = await comment_response.json() + if 'id' in comment: + if comment['id'] in handled_ids: + continue + else: + handled_ids.add(comment['id']) if 'user' in comment and 'login' in comment['user']: if comment['user']['login'] == user_id: continue