Skip to content

fix(settings): handle invalid session token on signin token code - #21263

Merged
vbudhram merged 1 commit into
mainfrom
fxa-13110
Sep 22, 2026
Merged

vbudhram merged 1 commit into
mainfrom
fxa-13110

Conversation

@vbudhram

@vbudhram vbudhram commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Because

  • The catch block around checkTotpTokenExists reads err.errno directly.
  • The auth client can reject with null or undefined. The read then throws a TypeError inside the async effect, and the error escapes as an unhandled rejection on /signin_token_code.
  • Sentry records this error as FXA-CONTENT-QWA.

This pull request

  • Reads err?.errno in the checkTotpTokenExists catch block in container.tsx.
  • Adds a test in container.test.tsx for a rejection with an undefined reason.

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-13110

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: the catch block after checkTotpTokenExists in container.tsx.
  • Suggested review order: container.tsx, then container.test.tsx.
  • Risky or complex parts: none. An error object with an errno keeps the same behavior.

Screenshots (Optional)

None. This change does not modify the user interface.

Other information (Optional)

  • The fxa-settings SigninTokenCode suites: 32 passed, 0 failed.
  • nx lint fxa-settings: exit 0.
  • Without the fix, the new test fails with TypeError: Cannot read properties of undefined (reading 'errno').
  • Functional tests did not run. CI covers them.

@vbudhram vbudhram added the auto label Sep 18, 2026
Copilot AI balanced review requested due to automatic review settings September 18, 2026 21:14
@vbudhram
vbudhram requested a review from a team as a code owner September 18, 2026 21:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

OAuth-native invalid tokens remain on an unusable page without triggering the recovery flow.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Handles invalid session tokens during TOTP status checks on the sign-in token-code page.

Changes:

  • Catches TOTP status lookup failures and redirects non-native OAuth flows.
  • Adds tests for invalid-token and other error paths.
  • Stabilizes the mocked auth client.
File summaries
File Description
container.tsx Handles TOTP lookup errors and updates effect dependencies.
container.test.tsx Tests redirect behavior across integration and error types.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/fxa-settings/src/pages/Signin/SigninTokenCode/container.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new catch can still produce an unhandled rejection for nullish rejection values.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread packages/fxa-settings/src/pages/Signin/SigninTokenCode/container.tsx Outdated
## Because

- The catch block around `checkTotpTokenExists` reads `err.errno` directly.
- The auth client can reject with null or undefined. The read then throws a TypeError inside the async effect, and the error escapes as an unhandled rejection on `/signin_token_code`.
- Sentry records this error as FXA-CONTENT-QWA.

## This pull request

- Reads `err?.errno` in the `checkTotpTokenExists` catch block in `container.tsx`.
- Adds a test in `container.test.tsx` for a rejection with an undefined reason.

## Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-13110

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The error handling is targeted, preserves other behavior, and has appropriate tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

getClientId: () => 'sync',
isSync: () => isSync,
wantsKeys: () => false,
requiresKeys: () => false,

@dschom dschom Sep 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, but is this applicable to changes on container.tsx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was added for the mock completeness, I'll keep it in since low risk.

@vbudhram
vbudhram merged commit 1c07b0e into main Sep 22, 2026
24 of 25 checks passed
@vbudhram
vbudhram deleted the fxa-13110 branch September 22, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants