Repository navigation
fix: copilot token cache ignores profile rotation on rate limit - #43659
faishalwahiduddin wants to merge 1 commit into
Conversation
Greptile SummaryThis PR correctly fixes the root cause of Copilot token cache collisions across GitHub profiles by binding each cached token to a SHA-256 fingerprint of the GitHub PAT used to obtain it. The change is minimal, backward-compatible (legacy entries without a fingerprint are treated as cache misses), and backed by three new focused tests. Key observations:
Confidence Score: 4/5
|
| /** Reproduce the same fingerprint the production code computes. */ | ||
| function fingerprintGithubToken(githubToken: string): string { | ||
| return createHash("sha256").update(githubToken).digest("hex").slice(0, 16); | ||
| } |
There was a problem hiding this comment.
Duplicated fingerprint helper couples tests to internal algorithm
fingerprintGithubToken is defined in both the test file and the production module. If the hashing algorithm or truncation length changes in production, the test helper would also need a matching update — and a reviewer could easily miss the second copy.
Consider exporting fingerprintGithubToken from github-copilot-token.ts (or a dedicated internal util) and importing it here, so the logic lives in exactly one place:
import { fingerprintGithubToken } from "./github-copilot-token.js";If keeping the function internal is intentional, adding a brief comment explaining why the duplication is deliberate would help future readers.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/providers/github-copilot-token.test.ts
Line: 8-11
Comment:
**Duplicated fingerprint helper couples tests to internal algorithm**
`fingerprintGithubToken` is defined in both the test file and the production module. If the hashing algorithm or truncation length changes in production, the test helper would also need a matching update — and a reviewer could easily miss the second copy.
Consider exporting `fingerprintGithubToken` from `github-copilot-token.ts` (or a dedicated internal util) and importing it here, so the logic lives in exactly one place:
```typescript
import { fingerprintGithubToken } from "./github-copilot-token.js";
```
If keeping the function internal is intentional, adding a brief comment explaining why the duplication is deliberate would help future readers.
How can I resolve this? If you propose a fix, please make it concise.|
The All code-level checks ( |
3a34108 to
d9fc3bd
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 3:40 PM ET / 19:40 UTC. Summary PR surface: Source +32, Tests +73. Total +105 across 3 files. Reproducibility: yes. at source level: current main can return a valid same-domain cached Copilot API token before using the newly selected GitHub token, so a rotated profile can inherit another account's token. I did not run a live two-account Copilot rotation because that needs real credentials. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Port the cache-ownership guard into src/plugin-sdk/provider-auth.ts, preserve the current integrationId and domain cache guards, add active-path regression coverage, and require redacted real multi-profile Copilot proof before merge. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main can return a valid same-domain cached Copilot API token before using the newly selected GitHub token, so a rotated profile can inherit another account's token. I did not run a live two-account Copilot rotation because that needs real credentials. Is this the best way to solve the issue? No as currently branched: fingerprinting the selected GitHub credential is a plausible narrow fix, but it must be applied to the active src/plugin-sdk/provider-auth.ts helper while preserving current integrationId and domain guards. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d64b9a30cb91. Label changesLabel justifications:
Evidence reviewedPR surface: Source +32, Tests +73. Total +105 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
d9fc3bd to
5c8531d
Compare
Update: Fix ported to correct file pathsThe previous commit in this PR targeted `src/providers/github-copilot-token.ts` which no longer exists in current `main`. The Codex automated review correctly identified this gap. This branch has been rebased onto upstream `main` and the fix has been ported to the two active file paths: Changes in this update`extensions/github-copilot/token.ts` (plugin runtime — primary path)
`src/agents/github-copilot-token.ts` (legacy agent helper — secondary path)
`extensions/github-copilot/models.test.ts` (token tests in the `github-copilot token` describe block)
Test resultsAll 26 tests pass. This addresses all points raised in the Codex and Greptile reviews. |
…#43658) Port the fix from PR openclaw#43659 to the correct active file paths. The original PR targeted src/providers/github-copilot-token.ts which no longer exists in current main. Changes: - extensions/github-copilot/token.ts: add githubTokenFingerprint field to CachedCopilotToken, export fingerprintGithubToken() helper, require fingerprint match on cache hit so profile rotation forces a fresh exchange - src/agents/github-copilot-token.ts: identical fix for the legacy agent path - extensions/github-copilot/models.test.ts: update cache-hit test to include fingerprint; add two regression tests (different profile bypasses cache, legacy entry without fingerprint treated as miss) Closes openclaw#43658 Co-authored-by: Copilot <[email protected]>
5c8531d to
a81ded1
Compare
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
Closes #43658
Problem
When multiple
github-copilotauth profiles are configured, profile rotation after a rate limit has no effect. All profiles end up using the same Copilot API token becauseresolveCopilotApiToken()caches to a single shared file (github-copilot.token.json) without tracking which GitHub account produced the token. A profile switch passes a different GitHub PAT, but the cache returns the still-valid token from the rate-limited account.Solution
Store a SHA-256 fingerprint (first 16 hex chars) of the GitHub PAT alongside the cached Copilot API token. On cache lookup, compare the fingerprint against the current profile's token. A mismatch forces a fresh token exchange with the GitHub Copilot token endpoint.
Changes
src/providers/github-copilot-token.tsgithubTokenFingerprintfield toCachedCopilotTokentypefingerprintGithubToken()helper (SHA-256, truncated to 16 hex chars)src/providers/github-copilot-token.test.tsBackward compatibility
githubTokenFingerprintare treated as a cache miss — the token is re-fetched on the next call and saved with a fingerprint. No migration needed.githubTokenFingerprintfield is optional (?) so older versions reading a new cache file won't break.Testing
All 38 auth-profiles tests also pass.