Skip to content

fix(model-gateway): authenticate the GitHub release lookup in setup - #718

Merged
Eigenwise merged 2 commits into
Eigenwise:developfrom
MadaBurns:mg-github-auth
Nov 9, 2026
Merged

Eigenwise merged 2 commits into
Eigenwise:developfrom
MadaBurns:mg-github-auth

Conversation

@MadaBurns

Copy link
Copy Markdown
Contributor

Summary

setup (and so update.js and /quartermaster:update-toolshed) looked up the latest claude-code-proxy release with an anonymous GitHub API call. Anonymous calls share 60 an hour per IP address, so a machine running several agents fails setup with a bare GitHub API returned 403, even when a working gh login is available.

 setup()
-  fetchUrl(api.github.com/.../releases/latest)              anonymous
+  fetchLatestRelease(REPO, { fetchUrl, log })
+    githubToken: GH_TOKEN → GITHUB_TOKEN → `gh auth token --hostname github.com` → anonymous
+    Authorization: Bearer <token> on the API call only
+    403/429 anonymous → "rate limited. Set GH_TOKEN or run `gh auth login`"
 fetchUrl redirect
-  forwards every header to the Location
+  drops Authorization when the redirect changes origin (other host, or https → http)

SKILL.md and getting-started/model-gateway.md describe the token sources and what an anonymous 403 means.

Evidence

  • Before: curl -D - https://api.github.com/repos/raine/claude-code-proxy/releases/latest showed x-ratelimit-remaining: 0, and setup died with "GitHub API returned 403". Six minutes after a reset, the anonymous allowance was already down to 21 of 60.
  • After: a live run printed "fetching latest release of raine/claude-code-proxy (authenticated via gh auth token)" and returned v0.1.47 with 12 assets. The authenticated limit is x-ratelimit-limit: 5000.
  • Tests: test/github-release.test.js has 10 cases, all passing, with 100% line, 96.55% branch and 100% function coverage of lib/github-release.js.
  • Negative controls:
    • Removing the bearer header fails "sends the token only as a bearer header".
    • Disabling redirect stripping fails the cross-host redirect test.
    • Comparing hosts instead of origins fails the https→http downgrade test.
  • Full suite: 694/708. The failing files (gateway-drain, gateway-process-isolation, wiring-mode) fail the same tests on untouched origin/develop 65d5e20: 10 failures on both trees.
  • CRAP: redirectRequest scores 2. setup's complexity fell.

Release fragment

No board ref. The fragment needs a maintainer-assigned ref (CONTRIBUTING, "Release fragment"). Suggested: --plugins model-gateway --bump patch.

Merge Danger

Door: two-way

With no token available, behaviour is unchanged. With a token, only the release lookup is authenticated.

Blast Radius: setup/update

Only setup's release lookup, and redirect handling in fetchUrl, change. Inference requests are untouched.

🤖 Generated with Claude Code

MadaBurns and others added 2 commits October 30, 2026 10:25
setup looked up the latest claude-code-proxy release anonymously. Anonymous
GitHub API calls share 60 an hour per IP address, so on a machine running
several agents setup (and update.js / update-toolshed) failed with a bare
"GitHub API returned 403" although a working gh login was available.

- lib/github-release.js: token from GH_TOKEN, then GITHUB_TOKEN, then
  `gh auth token --hostname github.com` (5 s timeout, no shell); falls back
  to anonymous. The token is sent only as a bearer header on the API call.
  A 403/429 refusal names the rate limit and the fix; no message carries
  the token.
- fetchUrl drops Authorization when a redirect leaves the original host.
- SKILL.md and the getting-started page describe the token sources and
  what an anonymous 403 means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare redirect origins (scheme, host and port), not hosts, so a downgrade
to http on the same host also drops Authorization. Pin it with a test that
fails on the host comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eigenwise added a commit that referenced this pull request Nov 9, 2026
GH-718: authenticate the GitHub release lookup in Model Gateway setup (PR #718)
@Eigenwise
Eigenwise merged commit 0059765 into Eigenwise:develop Nov 9, 2026
20 checks passed
@Eigenwise

Copy link
Copy Markdown
Owner

Merged into develop through #794 with a maintainer fragment (GH-718, model-gateway patch). The cross-origin Authorization drop on redirect was a good catch on top of the rate-limit fix. Thanks.

unifirer pushed a commit to unifirer/eigenwise-toolshed that referenced this pull request Nov 10, 2026
unifirer pushed a commit to unifirer/eigenwise-toolshed that referenced this pull request Nov 10, 2026
…lease lookup (patch)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
unifirer pushed a commit to unifirer/eigenwise-toolshed that referenced this pull request Nov 10, 2026
…ster 1.1.0, sidequest 6.9.0, repository (EigenwiseGH-681, EigenwiseGH-718, EigenwiseGH-782, SQ-3441, SQ-3442, SQ-3512, SQ-3830, SQ-3993, SQ-4024, SQ-4025, SQ-4032, SQ-4043, SQ-4046, SQ-4049, SQ-4057, SQ-4069, SQ-4078, SQ-4080, SQ-4083, SQ-4084, SQ-4085, SQ-4086, SQ-4087, SQ-4089, SQ-4092, SQ-4093)
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