Skip to content

Retry PyPI lookups and report outages in the version check - #467

Open
lelia wants to merge 7 commits into
mainfrom
lelia/version-check-pypi-retry
Open

lelia wants to merge 7 commits into
mainfrom
lelia/version-check-pypi-retry

Conversation

@lelia

@lelia lelia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The required version check queries PyPI for the latest published release. A dropped connection or rate limit can block a PR even when its version is valid.

Changes

  • Retry connection failures, timeouts, unreadable responses, HTTP 429, and HTTP 5xx, with four attempts and a 15-second request timeout. Use 2-, 4-, and 8-second backoff and honor longer Retry-After delays up to 60 seconds. If PyPI asks for a longer delay, fail with a rerun message.
  • Report lookup failures in the job log and PR comment so contributors know when to rerun the check.
  • Bump the package version to 2.16.1 and update the changelog.

Verification

  • Added 14 regression cases covering recovery, exhausted retries, HTTP 404, and Retry-After.
  • Ran the version check against live PyPI and exercised the PR comment paths with a mocked GitHub API.
  • Passed actionlint and Ruff.

check_version read the latest release from PyPI with one request and no
timeout, so a single dropped connection failed a required check and
blocked the merge until someone reran the job.

The request now has a 15 s timeout and is retried up to four times, with
2, 4 and 8 s pauses, on connection errors, timeouts and 5xx responses. If
PyPI still can't be read, the job fails with a message that names PyPI and
says the PR's version isn't the problem. The version comparison is
unchanged.

Also quotes $GITHUB_ENV, which actionlint's shellcheck pass flagged.
@lelia
lelia requested a review from a team as a code owner November 24, 2026 03:33
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to CI version-check plumbing and a new helper with tests; no runtime CLI or security-sensitive product paths.

Overview
Makes the required version check resilient when PyPI is flaky instead of failing PRs with valid version bumps.

The workflow now calls shared helper scripts.ci.pypi_lookup.fetch_pypi_releases() instead of a one-shot urllib fetch. It retries up to four times (15s timeout, exponential backoff, honors Retry-After up to 60s) on connection issues, bad JSON, HTTP 429, and 5xx; permanent HTTP errors fail immediately. Lookup failures set pypi_lookup_failed so the bot PR comment tells contributors to rerun when PyPI was unreachable, separate from ordinary version failures.

Package version is bumped to 2.16.1 with changelog and uv.lock. Unit tests cover retry recovery, exhausted retries, 404, and Retry-After handling.

Reviewed by Cursor Bugbot for commit e82f40a. Configure here.

@lelia

lelia commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor 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.

Stale Bugbot comment from a previous run.

main released 2.15.1, which this branch was riding unreleased.
@lelia
lelia temporarily deployed to socket-firewall November 24, 2026 23:36 — with GitHub Actions Inactive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Logic looks right, HTTPError is caught ahead of OSError, so 4xx fails fast and 5xx retries, and the backoff matches the description. Also consider retrying 429, since a PyPI rate limit is as transient as a 503.

lelia added 2 commits December 4, 2026 23:43
A rate limit is as transient as a 5xx, so it gets the same backoff
instead of failing the required check on the first attempt.

Bump to 2.15.11, since main has released 2.15.10.
@lelia
lelia temporarily deployed to socket-firewall December 5, 2026 04:43 — with GitHub Actions Inactive
@lelia
lelia deployed to socket-firewall December 5, 2026 06:24 — with GitHub Actions Active
@lelia

lelia commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Logic looks right, HTTPError is caught ahead of OSError, so 4xx fails fast and 5xx retries, and the backoff matches the description. Also consider retrying 429, since a PyPI rate limit is as transient as a 503.

Orlando Barrera II (@obarrera) good catch on that, fixed in latest commits - LMK if you're good to approve!

Retry unreadable responses, honor bounded Retry-After delays, and report PyPI lookup failures in PR comments. Add regression coverage for retry and failure paths.
@lelia lelia changed the title Retry the PyPI lookup in the version check Retry PyPI lookups and report outages in the version check Dec 5, 2026
@lelia
lelia deployed to socket-firewall December 5, 2026 07:16 — with GitHub Actions Active
@lelia

lelia commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e82f40a. Configure here.

This branch was successfully deployed

1 active deployment
socket-firewall — e82f40a9 Deployed Dec 5, 2026 by lelia via python-sfw-smoke-enterprise #763
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