Files
magpie/docs
NightGlowww 131037e2ba gateway: preserve Codex model-list OAuth alongside gateway keys
A managed x-api-key made identifyCaller overwrite Codex's valid ChatGPT
bearer with the internal token. /models then forwarded that token and
returned 401, losing the configured model metadata (#5197).

Keep the bearer privately only for the native model-list GET after key
validation. Restore it on a request copy used by both the model-list
cache and its upstream ask, removing gateway authentication fields.
Key-only requests remain refused; other routes keep normalization.

Verification on Go 1.27.3, macOS arm64, based on 17154e165:
- TestCodexModelsKeepOAuthBesideGatewayKey fails on the unmodified base
  with 401 invalid client sign-in, then passes with this fix.
- Four new test groups pass, including -race -count=20.
- Full nogui suite completed: 84 packages passed, 3 packages failed.
  Existing gateway JSONv2 parity (#3547, including a separate invalid
  UTF-8 sizing difference) and WSL probe (#3680) failures reproduced
  on unmodified base. GUI: core budget (#5139, reproduced on base),
  lane-test isolation (#5150), system-proxy isolation (#2562).
  Plugin git-update tests failed with PATH Bun 1.3.14 on base and patch,
  then passed with bundled Bun 1.4.4. Existing issue patches reviewed;
  separate fixes are not bundled into this OAuth change.
  TestRemoveServerDropsItsIcon skipped: user forbids Playwright setup.
  The full suite is not claimed green.
- gofmt -l and git diff --check are clean.
- macOS, Linux (nogui), Windows: go vet ./... and go build pass.
- Isolated patched Server.Front plus a real OAuth and fresh gateway key:
  GET /models returns 200 and Astra's native 272000/max 872000 entry.
  The explicit 872000 override is checked by the regression fixture.

Tests isolate HOME and pin Go caches. No production replacement or
inference probe; no Linux/Windows runtime or GUI/Playwright run.

Landed from @ggbdpq's verification on #5197. The review dropped the
patch's change to the Codex model-list bullet in gateway-routing.md: it
put back an older text (provider.CodexListed, without CodexListedBeside
and keyListed/GroupStandIns). main's bullet is kept as it is, and only
the new paragraph is added.

Run at this commit's tree on mica: with codex_backend.go and lan.go at
origin/main d987cc7d5 and the new test file kept, all four tests fail
(TestCodexModelsKeepOAuthBesideGatewayKey: 401 "invalid client sign-in";
TestCodexModelsGatewayKeyIsNotOAuth: 200 where a local 401 is wanted;
TestCodexModelsOAuthStillNeedsAnEnabledGatewayKey;
TestCodexModelsCacheUsesClientOAuth). With the change they pass. Full
suite: see the batch's last commit.
Not tried: a real Codex app beside a gateway key.
2026-11-14 19:46:12 +08:00
..