fix(auth): surface 'No token' dispatch failure as AuthError::NoToken#3721
Open
sandikodev wants to merge 1 commit intoaws:mainfrom
Open
fix(auth): surface 'No token' dispatch failure as AuthError::NoToken#3721sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev wants to merge 1 commit intoaws:mainfrom
Conversation
When a session expires mid-chat, the AWS SDK returns a dispatch failure with 'No token' in the error chain. This was converted to ChatError::Client and displayed as an opaque multi-line error instead of the clear 'Your session has expired. Run q login' message. Add is_no_token_error() to walk the error source chain and detect this case, converting it to ChatError::Auth(AuthError::NoToken) so the existing handler in handle_chat_error displays the actionable message. Fixes aws#3173
ad6e6bf to
aec6f6c
Compare
Author
|
Update (amended commit): Tests were added after initial submission covering four cases:
This ensures the error chain walking logic is correct and the |
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.
Issue
Closes #3173
Problem
When a session expires mid-chat, the AWS SDK returns a
DispatchFailurewith"No token"in the error chain. This was converted toChatError::Clientand displayed as an opaque multi-line error:The handler for
ChatError::Auth(AuthError::NoToken)already exists and displays a clear, actionable message — but it was never reached because the error was wrapped asChatError::Client.Fix
Add
is_no_token_error()which walks the error source chain to detect the"No token"string. InFrom<ApiClientError> for ChatError, check for this condition and convert toChatError::Auth(AuthError::NoToken)so the existing handler is triggered, showing:Testing
Four tests cover all cases:
detects_auth_no_token—ApiClientError::AuthError(AuthError::NoToken)is detectedignores_unrelated_errors— unrelated errors (e.g.DefaultModelNotFound) are not detectedfrom_api_client_error_converts_no_token_to_auth_error—Fromconversion producesChatError::Auth(AuthError::NoToken)from_api_client_error_keeps_other_errors_as_client— other errors remain asChatError::ClientBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.