Skip to content

[CI] Paginate and retry reviewer assignment - #9377

Merged
tlively merged 1 commit into
mainfrom
reviewer-assignment-timeout
Nov 9, 2026
Merged

tlively merged 1 commit into
mainfrom
reviewer-assignment-timeout

Conversation

@tlively

@tlively tlively commented Nov 9, 2026

Copy link
Copy Markdown
Member

The single GraphQL query in scripts/assign_reviewer.py fetched 100 recent PRs with three nested first: 100 connections (latestReviews, reviewRequests, and timelineItems) in one request, which intermittently exceeded GitHub's 10-second GraphQL execution timeout and failed with HTTP 502 (such as on PR #9357 and PR #9368).

Split the initial team and target PR lookup into SETUP_QUERY so closed, draft, or already-assigned PRs exit early without fetching PR history, paginate RECENT_PRS_QUERY across two pages of 50 PRs with first: 20 on latestReviews and reviewRequests, and retry transient GitHub API 5xx errors in gh_api with exponential backoff.

The single GraphQL query in scripts/assign_reviewer.py fetched 100 recent PRs with three nested first: 100 connections (latestReviews, reviewRequests, and timelineItems) in one request, which intermittently exceeded GitHub's 10-second GraphQL execution timeout and failed with HTTP 502 (such as on PR #9357 and PR #9368).

Split the initial team and target PR lookup into SETUP_QUERY so closed, draft, or already-assigned PRs exit early without fetching PR history, paginate RECENT_PRS_QUERY across two pages of 50 PRs with first: 20 on latestReviews and reviewRequests, and retry transient GitHub API 5xx errors in gh_api with exponential backoff.
@tlively
tlively requested a review from a team as a code owner November 9, 2026 20:06
@tlively
tlively requested review from stevenfontanella and removed request for a team November 9, 2026 20:06

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the reviewer assignment script by splitting the monolithic GraphQL query into setup and paginated recent PR queries, reducing requested node limits, and introducing a retry mechanism with exponential backoff for transient GitHub API errors. The review feedback suggests enhancing the retry mechanism by expanding the list of retryable network errors and adopting defensive programming to handle potential null values in the GraphQL response nodes safely.

Comment on lines +34 to +40
RETRYABLE_ERRORS = (
'HTTP 500',
'HTTP 502',
'HTTP 503',
'HTTP 504',
'Something went wrong while executing your query',
)

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

To make the script more resilient against transient network issues in CI environments, consider expanding RETRYABLE_ERRORS to include common network-level error messages (such as DNS lookup failures, connection timeouts, or connection resets).

Suggested change
RETRYABLE_ERRORS = (
'HTTP 500',
'HTTP 502',
'HTTP 503',
'HTTP 504',
'Something went wrong while executing your query',
)
RETRYABLE_ERRORS = (
'HTTP 500',
'HTTP 502',
'HTTP 503',
'HTTP 504',
'Something went wrong while executing your query',
'dial tcp',
'i/o timeout',
'connection refused',
'TLS handshake',
)

Comment on lines +204 to +207
for pr in page['nodes']:
if pr['number'] not in seen:
seen.add(pr['number'])
prs.append(pr)

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

To prevent potential TypeError exceptions if the GraphQL response contains a null value for the nodes field (which can happen under certain partial failure modes in GraphQL), use defensive programming with .get() and a fallback empty list.

Suggested change
for pr in page['nodes']:
if pr['number'] not in seen:
seen.add(pr['number'])
prs.append(pr)
for pr in page.get('nodes') or []:
if pr['number'] not in seen:
seen.add(pr['number'])
prs.append(pr)

@tlively
tlively enabled auto-merge (squash) November 9, 2026 20:18
@tlively
tlively disabled auto-merge November 9, 2026 20:28
@tlively
tlively merged commit 0bfa72e into main Nov 9, 2026
19 checks passed
@tlively
tlively deleted the reviewer-assignment-timeout branch November 9, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants