Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions scripts/assign_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,15 @@ def main() -> None:
if n['requestedReviewer']
)
if team_requested:
try:
gh_api([
'--method',
'DELETE',
f'repos/{owner}/{name}/pulls/{pr_number}/requested_reviewers',
'-f',
f'team_reviewers[]={TEAM_SLUG}',
])
except subprocess.CalledProcessError as e:
detail = e.stderr.strip() if e.stderr else str(e)
print(
f'Note: could not remove team review request: {detail}',
file=sys.stderr,
)
gh_api([
'--method',
'DELETE',
f'repos/{owner}/{name}/pulls/{pr_number}/requested_reviewers',
'-f',
'reviewers[]',
'-f',
f'team_reviewers[]={TEAM_SLUG}',
])
Comment on lines +313 to +321

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing the try...except block makes the script fragile. If the DELETE request to remove the team review request fails (for example, due to transient GitHub API issues or permission limitations), the entire script will crash with an unhandled subprocess.CalledProcessError. Since the primary action of assigning the individual reviewer has already succeeded, this cleanup step should fail gracefully rather than crashing the script.

Suggested change
gh_api([
'--method',
'DELETE',
f'repos/{owner}/{name}/pulls/{pr_number}/requested_reviewers',
'-f',
'reviewers[]',
'-f',
f'team_reviewers[]={TEAM_SLUG}',
])
try:
gh_api([
'--method',
'DELETE',
f'repos/{owner}/{name}/pulls/{pr_number}/requested_reviewers',
'-f',
'reviewers[]',
'-f',
f'team_reviewers[]={TEAM_SLUG}',
])
except subprocess.CalledProcessError as e:
detail = e.stderr.strip() if e.stderr else str(e)
print(
f'Note: could not remove team review request: {detail}',
file=sys.stderr,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather hear loudly about failures, even after the main action has been completed successfully.



if __name__ == '__main__':
Expand Down
Loading