Repository navigation
Conversation
A client that ignores the invalid_token challenge keeps presenting the same credential, and every retry became a GET /usage the API records as a 401. On 2026-10-23 one copilot-cli install pinged every six seconds with a rejected token: about 10.7k 401s, a third of the API's errors that day. Remember a definite rejection for 60 seconds, keyed by the credential's SHA-256. Validation failures (503) are not remembered, and the short TTL bounds how long a valid OAuth token stays locked out if Clerk briefly reports it as unauthenticated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
Closing as a duplicate of #51, which makes the same change (60s cache of rejected credentials keyed by SHA-256, outages not cached). #51 is green and mergeable. Generated by Claude Code |
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.
Requested by fatwang2
Why
The API's error count tripled on 2026-10-23 (Beijing time). About 10.7k of the 31.4k errors were
GET /usage401s from the MCP host:validateCredentialcalls/usageon every MCP exchange. Current container logs show one client (userAgent: copilot-cli) sendingpingwith a rejected credential every six seconds. It ignores theinvalid_tokenchallenge and never reauthorizes. Each ping cost an API call that was recorded as a 401, and it is still going.What
rememberRejections()wraps the credential validator increateHttpApp. A definite rejection (null) is remembered for 60 seconds, keyed by the credential's SHA-256 digest, with at most 1,000 entries (the oldest is evicted first). A repeat within that window gets the same 401invalid_tokenchallenge without calling/usage.For the six-second pinger this cuts
/usagecalls from about 600 to about 60 per hour.Tests
invalid_token, while two outage responses validate twice.npm test: 49/49 pass.🤖 Generated with Claude Code