Skip to content

fix: add retry with backoff to _fetch_closed_issues for transient 5xx errors#394

Closed
t7929375-eng wants to merge 2 commits intoentrius:testfrom
t7929375-eng:fix/repo-scan-retry-on-transient-errors
Closed

fix: add retry with backoff to _fetch_closed_issues for transient 5xx errors#394
t7929375-eng wants to merge 2 commits intoentrius:testfrom
t7929375-eng:fix/repo-scan-retry-on-transient-errors

Conversation

@t7929375-eng
Copy link
Copy Markdown
Contributor

@t7929375-eng t7929375-eng commented Apr 12, 2026

Problem

_fetch_closed_issues() in repo_scan.py has no retry logic. A single transient 502/503/504 from GitHub causes the function to immediately break and return partial results, silently losing all issues from subsequent pages.

This is inconsistent with every other API function in the codebase:

  • get_pull_request_file_changes — 3 retries with exponential backoff
  • get_pull_request_maintainer_changes_requested_count — 3 retries
  • execute_graphql_query — 8 retries with backoff
  • get_merge_base_sha — 3 retries
  • get_github_user — 6 retries

Impact

When GitHub returns a transient 5xx during the issue discovery scan, the validator loses visibility into all remaining closed issues for that repo.

Solution

Add retry logic with exponential backoff (3 attempts, capped at 30s) for 5xx errors and connection exceptions, matching the established pattern. Non-retryable errors (404, 422) still return immediately.

Type of Change

  • Bug fix

Testing

  • 9 unit tests in tests/validator/test_repo_scan_retry.py:
    • Success on first attempt (no sleep)
    • Retry on 502/503 with eventual success
    • All retries exhausted returns partial results
    • 404/422 return immediately without retry
    • ConnectionError triggers retry
    • Exponential backoff timing verification (5s, 10s)
    • Pagination continues after mid-page retry
  • ruff check passes
  • ruff format passes
  • pyright passes
  • All existing tests pass

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added

cc @anderdc @LandynDev

@anderdc anderdc force-pushed the fix/repo-scan-retry-on-transient-errors branch from 1d8a3e2 to 8886a97 Compare April 14, 2026 04:16
Covers:
- Success on first attempt (no sleep)
- Retry on 502/503 with eventual success
- All retries exhausted returns partial results
- 404/422 return immediately without retry
- ConnectionError triggers retry
- Exponential backoff timing (5s, 10s)
- Pagination continues after mid-page retry
@anderdc anderdc closed this Apr 14, 2026
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