fix: handle invalid_grant as permanent auth error with improved resilience#69
Open
RaphaelManke wants to merge 1 commit intotickernelz:masterfrom
Open
Conversation
…ience - Add 'Invalid grant provided' and 'invalid_grant' to isPermanentError() so accounts fail fast instead of retrying 10 times with a dead token - Catch 'Invalid grant provided' message in token-refresher error handler - Fix CLI sync skip condition to also check token is not already expired (prevents stale-but-healthy tokens from blocking fresher CLI tokens) - Log writeToKiroCli failures instead of silently swallowing them Fixes cases where refresh token rotation or server-side revocation caused KiroTokenRefreshError: Refresh failed: Invalid grant provided
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.
Problem
When the Kiro server returns
invalid_grant/Invalid grant providedduring token refresh, the error was not recognized as a fatal auth failure. This caused the plugin to:writeToKiroClifailures, causing stale tokens to persistChanges
Invalid grant providedandinvalid_granttoisPermanentError()so accounts fail fastInvalid grant providedintoken-refreshererror handlerexpires_at > Date.now())writeToKiroClifailures instead of silently swallowing themRoot cause
invalid_grantis returned when a refresh token is revoked, expired server-side, or invalidated by a concurrent refresh (rotation race). The fix ensures these are treated as permanent failures requiring re-authentication rather than transient errors worth retrying.Related to #43 #49