Skip to content

fix: retry _gh_get once on transient network failure before giving up - #584

Open
essentialbit wants to merge 2 commits into
mainfrom
fix/gh-get-retry-transient-failure
Open

fix: retry _gh_get once on transient network failure before giving up#584
essentialbit wants to merge 2 commits into
mainfrom
fix/gh-get-retry-transient-failure

Conversation

@essentialbit

Copy link
Copy Markdown
Owner

Summary

  • community._gh_get() returned None on any request exception or non-200 response, with no distinction from a legitimate final empty page.
  • Every paginating caller (pr_merge_planner.py, and scripts/audit_stale_branches.py in open PR chore: add read-only stale/orphan branch audit script #583) uses if not batch: break — a transient network hiccup mid-pagination silently truncated results instead of erroring. Hit once for real: audit_stale_branches.py's branch fetch silently dropped from 172 to 100 branches on page 2 before a manual re-run recovered it.
  • Adds one retry (2s delay) inside _gh_get itself before giving up, closing the gap for every caller of this shared helper without touching each script's own loop shape.

Test plan

  • from community import _gh_get imports cleanly
  • from main import * still imports cleanly (shared module surface)
  • Mocked-requests scratch verification (3 cases, all pass):
    • transient failure on attempt 1, success on attempt 2 → returns real data, exactly 2 attempts
    • persistent failure both attempts → returns None, exactly 2 attempts (bounded, no infinite retry)
    • legitimate empty page (200, []) on first try → returns [] immediately, no spurious retry
  • No tests/ directory exists in this repo yet (consistent with other recent PRs)

🤖 Generated with Claude Code

Every paginating caller (pr_merge_planner.py, audit_stale_branches.py in
PR #583, etc.) treats a falsy _gh_get() return as end-of-data via
`if not batch: break`. A transient network error or 5xx mid-pagination
returned None, which looked identical to a legitimate empty final page —
silently truncating results with no error surfaced (hit once auditing
branches: 172 -> 100, page 2 lost). One retry after a short delay closes
that gap for every caller sharing this shared helper, without touching
each script's loop shape individually.
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.

1 participant