Add validation checks for 'latest_comment' and 'pr_url' in GitHub polling server

This commit is contained in:
mrT23
2024-08-19 14:18:45 +03:00
parent 9bec97c66c
commit b034d16c23

View File

@ -80,6 +80,8 @@ async def polling_loop():
if 'subject' in notification and notification['subject']['type'] == 'PullRequest': if 'subject' in notification and notification['subject']['type'] == 'PullRequest':
pr_url = notification['subject']['url'] pr_url = notification['subject']['url']
latest_comment = notification['subject']['latest_comment_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: async with session.get(latest_comment, headers=headers) as comment_response:
if comment_response.status == 200: if comment_response.status == 200:
comment = await comment_response.json() comment = await comment_response.json()