Skip to content

Conversation

@soberm
Copy link
Contributor

@soberm soberm commented Nov 4, 2025

Description of changes

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

anivar and others added 19 commits September 26, 2025 12:02
…learing

Fixes the critical issue where users are randomly logged out due to TokenOrchestrator clearing tokens for ANY non-network error, including transient AWS service issues.

Resolves #14534

The `handleErrors()` method was clearing tokens for all errors except NetworkError, causing users to be logged out during:
- AWS service errors (500s)
- Rate limiting (TooManyRequestsException)
- Temporary service unavailability
- Other transient errors that should be retried

Modified token clearing logic to only clear tokens for definitive authentication failures that require re-authentication. Transient errors now preserve tokens, allowing for retry without forcing users to log in again.

- Removed overly broad token clearing condition
- Added `isAuthenticationError()` helper to identify auth failures
- Only clears tokens for errors that definitively indicate invalid/expired tokens
- Preserves tokens for all transient/retryable errors

- `NotAuthorizedException` - Refresh token expired/invalid
- `TokenRevokedException` - Token explicitly revoked
- `UserNotFoundException` - User no longer exists
- `PasswordResetRequiredException` - Password reset required
- `UserNotConfirmedException` - Account not confirmed

- `InternalErrorException` - AWS service errors
- `TooManyRequestsException` - Rate limiting
- `ThrottlingException` - Request throttling
- `ServiceUnavailable` - Temporary service issues
- `NetworkError` - Network connectivity issues
- Any other transient or unknown errors

- Added comprehensive test coverage for all error scenarios
- Tests verify correct token clearing behavior for each error type
- All existing tests pass

This fix ensures users remain logged in during temporary AWS service issues while still properly handling genuine authentication failures.
@soberm soberm requested review from a team, avi-karthik, pranavosu and sarayev as code owners November 4, 2025 10:39
@soberm soberm requested a review from Simone319 November 4, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants