fix(proxy): invalidate token-exchange cache on 429 - #69
Conversation
📦 Previous Review (superseded by newer review)Claude finished @andybons's task in 1m 54s —— View job Code review complete
SummaryThis is a well-scoped fix. I traced the cache logic end-to-end (
One nit (posted inline): the doc comment above Note: I was unable to run |
📦 Previous Review (superseded by newer review)Claude finished @andybons's task in 1m 29s —— View job Code review:
|
📦 Previous Review (superseded by newer review)Claude finished @andybons's task in 1m 5s —— View job Re-review complete (after latest push)
SummaryTwo commits landed since my last review:
No new security, race, or logic issues in this diff. The One nit: the generalization in 9af069c didn't reach two other spots that use the same "long-running box" phrasing introduced earlier in this PR:
Since the point of the latest commit appears to be scrubbing that internal terminology from the regression test, these two remaining instances are likely worth the same treatment for consistency (e.g. "a long-running client"). Not a functional issue — just a documentation/wording consistency gap. Note: |
📦 Previous Review (superseded by newer review)Claude finished @andybons's task in 2m 2s —— View job Reviewing PR #69
|
📦 Previous Review (superseded by newer review)Claude finished @andybons's task in 1m 51s —— View job Re-review complete (after latest push)
SummaryThe approach behind this PR changed completely since the last review. Commits Net effect vs.
I re-verified the reasoning by hand:
No security, race, or logic issues found in the new diff. Not run: |
|
Thanks for the re-review. Confirmed the current PR title and description were updated after the pivot: they describe 429-triggered eviction, no retry, the existing 10-second cooldown, and the red/green account A → account B regression. There are no remaining |

Summary
Problem
Some upstream APIs use HTTP 429 to report that a selected backing credential has exhausted its allowance while its token remains otherwise valid. For example, Codex maps
usage_limit_reachedfrom a 429 response inapi_bridge.rs. Without invalidation, Gatekeeper continues serving the cached credential until expiry even when the broker would select a different backing credential on the next exchange.Regression coverage
TestIntercept_TooManyRequestsInvalidatesCachedCredentialproves that:Before 429 was added to the invalidation statuses, this regression failed because the second request reused account A. With the fix, the second request resolves and sends account B.
Verification
go test -race ./proxy -run 'TestIntercept_(TooManyRequestsInvalidatesCachedCredential|UpstreamAuthFailureInvalidatesCredential)' -count=1go test -race ./...go vet ./...go build ./...