fix: clear a permanent main refresh latch when the refresh token rotates - #195
Merged
ualtinok merged 1 commit intoSep 2, 2026
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
iceteaSA
force-pushed
the
fix/relogin-clears-permanent-latch
branch
from
September 2, 2026 17:55
148cd75 to
a81806e
Compare
A permanent invalid_grant on the main OAuth account can outlive a re-login when the stable slot identity does not change. Persist the fingerprint of the refresh token that produced a refresh error and ignore active backoff when the current credential's fingerprint differs. The same lineage check now applies to fallback refreshes, and reset-backoff clears the main refresh and quota latches explicitly. Existing fingerprint-less records need one /claude-account reset-backoff; every error recorded by this build carries the fingerprint.
iceteaSA
force-pushed
the
fix/relogin-clears-permanent-latch
branch
from
September 2, 2026 18:33
a81806e to
f095ad5
Compare
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.
Incident (2026-09-02, live)
The main account's background refresh got
400 invalid_grant "Refresh token expired"at 15:35Z. The plugin recorded it aspermanent: truewith a 24hnextRetryAt, keyed to the main account's rotation-invariant slot id (v1.21.0). The operator re-logged in at 16:17Z: new refresh + access token inauth.json, same slot. The latch did not clear. Every tick loggedskipped backoff, the next due refresh would have been skipped, and the fresh 8h token would have died at expiry with a valid family on disk.Before v1.21.0 the error was keyed to the refresh-token hash, so a new token cleared it. Re-keying to the stable identity (#164) lost that edge:
clearStaleMainRefreshErroronly clears on identity mismatch, and re-login into the same slot leaves the identity unchanged by design.Fix
refreshTokenFingerprint(non-reversibletokenFingerprint()of the refresh token that was actually sent) on every refresh error, main and fallback.refreshBackoffActive(error, identity, now, currentFingerprint): an error whose recorded fingerprint differs from the current refresh token's is stale evidence — the family rotated or re-logged under the same slot — and no longer holds the backoff. Threaded at all six main call sites and all six fallback call sites.clearStaleMainRefreshErroralso clears and persists on fingerprint change./claude-account reset-backoff(OpenCode + Pi): explicit operator escape hatch that clearsmainLastRefreshErrorand the quota-API error under the current identity through the locked save path, bumping the generation / clearedAt fences so a stale cross-process writer cannot resurrect them.Errors recorded before this change carry no fingerprint. Those hold until identity change or one
reset-backoff— stated in the commit body and pinned by a test. Every error recorded from now on clears on re-login.Proof
reset-backoffclears; next tick attempts. Mutation (Pi persistence removed): ENOENT, red.account.refreshnow F2 → refresh attempted; mutation red.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes a permanent refresh backoff latch that survived re-login into the same account slot, which could let a fresh access token expire despite a valid refresh token on disk.
Bug Fixes
Migration
/claude-account reset-backoff./claude-account reset-backofffor OpenCode and Pi to explicitly clear main refresh and quota backoff.Written for commit f095ad5. Summary will update on new commits.