Skip to content

test(mcp): unique client_id per oauth test config — port reuse poisoned the global token cache - #855

Merged
jarvis9443 merged 1 commit into
mainfrom
test/oauth-cache-test-isolation
Jul 30, 2026
Merged

test(mcp): unique client_id per oauth test config — port reuse poisoned the global token cache#855
jarvis9443 merged 1 commit into
mainfrom
test/oauth-cache-test-isolation

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

The oauth token cache is process-global, keyed by (token_url, client_id, secret, scopes). Every test spawns its mock IdP on an ephemeral port — but the OS can hand a later test the port a finished test just released. With the identical cid/s3cret every test used, the cache key then collides and the later test is served the earlier test's cached token, its own endpoint recording zero hits. Observed as a CI flake on second_call_within_expiry_hits_the_cache (hits: left 0, right 1) on the unrelated #853.

config() now mints a unique client_id per call (the key includes it), keeping every test's cache slice disjoint no matter how ports recycle. Two touched tests: the exact-form assertion now follows the cfg value, and same_client_different_scopes_mint_distinct_tokens derives both configs from one cloned base so it still exercises same-client semantics.

Test-only change; no product code touched.

…use poisoned the global token cache

The oauth token cache is process-global, keyed by (token_url,
client_id, secret, scopes). Every test spawns its endpoint on an
ephemeral port, and the OS can hand a later test the port a finished
test just released; with identical 'cid'/'s3cret' in every config the
cache key collided and the later test was served the earlier test's
token — its own endpoint recording zero hits. Observed as a CI flake
on second_call_within_expiry_hits_the_cache (hits: left 0, right 1)
on an unrelated PR (#853).

config() now mints a unique client_id per call, keeping every test's
cache slice disjoint however ports recycle. The exact-form assertion
follows the cfg value, and same_client_different_scopes derives both
configs from one base so it still tests same-client semantics.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 079601cb-0ddb-47a9-a07c-6da06e2bea76

📥 Commits

Reviewing files that changed from the base of the PR and between 0866202 and 7d10e0e.

📒 Files selected for processing (1)
  • crates/aisix-mcp/src/oauth.rs

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 merged commit 41388a4 into main Jul 30, 2026
10 checks passed
@jarvis9443
jarvis9443 deleted the test/oauth-cache-test-isolation branch July 30, 2026 10:02
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.

1 participant