fix(*): resolve releases without spending the github api quota - #295
Open
arelchan wants to merge 1 commit into
Open
fix(*): resolve releases without spending the github api quota#295arelchan wants to merge 1 commit into
arelchan wants to merge 1 commit into
Conversation
`raven upgrade` and both installers resolved the latest release through api.github.com with no credentials. GitHub meters unauthenticated API requests at 60 per hour per IP address, so every machine behind one office NAT draws down a single shared counter: once it is spent, upgrading and installing both fail with a 403 that the CLI reported as "Check your network and try again", sending users to diagnose the wrong thing. Resolve the release from the plain github.com redirect instead (releases/latest -> releases/tag/vX.Y.Z), which is not the REST API and has no such per-IP quota. Asset names follow from the tag, and the payload parser already required the wheel URL to be exactly the one the tag implies, so nothing is lost. The API stays as a fallback and now sends GITHUB_TOKEN / GH_TOKEN when either is set, which moves a developer or CI run onto its own 5000-per-hour quota. An exhausted quota is now identified from x-ratelimit-remaining and reported with the reset time from x-ratelimit-reset, and UpgradeError carries an optional hint so that message replaces the generic network advice instead of being appended to it. Both installers say the same thing and point at GITHUB_TOKEN and RAVEN_WHEEL_URL. Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
raven upgradeand both installers resolved the latest release throughapi.github.comwith no credentials. GitHub meters unauthenticated API requests at 60 per hour per IP
address, so every machine behind one office NAT draws down a single shared counter. Once
it is spent, upgrading and installing both stop working:
The network was fine. The advice sent the user to diagnose the wrong thing, and the same
quota takes down
install.sh, which dies with "Could not resolve the latest raven releasewheel". The pending startup update check (24h TTL) adds one request per user per day to the
same shared counter, so this gets worse, not better, as adoption grows inside a company.
This resolves the release from the plain
github.comredirect instead:That is not the REST API and carries no per-IP API quota. Asset names are deterministic, and
_parse_release_payloadalready required the wheel URL to be exactly the one the tag implies,so nothing is lost by not reading the API payload. Downloads never counted against the API
quota, so the whole install and upgrade path can now run without spending any of it.
The API stays as a fallback and now sends
GITHUB_TOKEN/GH_TOKENwhen either is set,which moves a developer or CI run onto its own 5000-per-hour quota. An exhausted quota is
recognised from
x-ratelimit-remainingand reported with the reset time fromx-ratelimit-reset;UpgradeErrorgrew an optionalhintso that message replaces thegeneric network advice rather than being appended to it.
Not in this PR: publishing a
latest.jsonnext to the hosted installer, which would alsoallow staged rollouts and a fast rollback of a bad release. That needs a change to the
release workflow and to what the site serves, so it is worth doing separately.
Type
Verification
uv run pytest tests/test_cli_upgrade_commands.py-> 109 passed. New cases cover: theredirect is preferred and the API is not called at all; the redirect is never followed even
on a client configured to follow redirects; three malformed redirect shapes each fall back to
the API;
GITHUB_TOKENandGH_TOKENeach produce anAuthorizationheader (and no headeris sent when neither is set); an exhausted quota raises with the limit, the reset time and a
token hint; the hint drops the token advice when a token is already in use; a 403 that is not
a quota failure stays an
httpx.HTTPStatusError; and_release_from_tagproduces exactlywhat
_parse_release_payloadaccepts. One CLI-level case asserts the hint replaces the"Check your network" line.
install.shwas run end to end against stubuv/node/npmwith acurlwrapper thatblocks one endpoint at a time, from a directory that is not a checkout:
.../download/v0.1.11/raven-0.1.11-py3-none-any.whlapi.github.comblockedThe Python redirect path was also run against the live endpoint:
_fetch_latest_release_via_redirectreturnedReleaseInfo(version='0.1.11', wheel_url='https://github.com/EverMind-AI/Raven/releases/download/v0.1.11/raven-0.1.11-py3-none-any.whl').ruff check,ruff format)install.ps1was reviewed by reading, not executed: this was verified on macOS. Its redirectprobe is wrapped so that any failure, including the PowerShell 5.1 behaviour of raising on a
3xx, returns
$nulland falls through to the previous API path. The worst case is thereforetoday's behaviour, not a broken Windows install.
Risk
Notes: the wheel URL is still constrained to
github.com/EverMind-AI/Raven/releases/download/by
_parse_release_payload, and the tag pattern only acceptsvX.Y.Z, so the redirect cannotpoint the installer at another host. A token is read from the environment and sent only to
api.github.com.releases/latestexcludes drafts and prereleases in both the web and APIforms, so the stability check is preserved. Rollback is a revert of this commit.
Related Issues
N/A