Skip to content

Commit 869b645

Browse files
authored
fix(mfa): send users at the wallet pairing limit to support (#47537)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/MUL-2452 ## **Manual testing steps** No manual testing steps ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Localized MFA error routing and copy changes with test coverage; no auth or server logic changes. > > **Overview** > When MFA returns **`max_identifiers_reached`** (profile has hit the wallet pairing cap), the flow now treats it like **`multi_primary_srp`**: **`support`** handling instead of a terminal **`failure`**. > > Users see the dedicated support failure copy (`mfaFailureSupportTitle` / `mfaFailureSupportDescription`) and can open support with **`mfa_error=max_identifiers_reached`** in the link. **`max_passkeys_reached`** stays a generic limit failure with dismiss-only. > > Tests and **`getErrorHandling`** expectations were updated; **`max_identifiers_reached`** was removed from the generic limit message map so it no longer shares **`mfaErrorLimitReached`** with passkey limits. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8b22dc7. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2311409 commit 869b645

4 files changed

Lines changed: 41 additions & 33 deletions

File tree

‎ui/hooks/identity/mfa/engine/errors.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe('getErrorHandling', () => {
1111
['invalid_code', 'inline'],
1212
['flow_expired', 'restart'],
1313
['otp_resend_cooldown', 'cooldown'],
14-
['max_identifiers_reached', 'failure'],
14+
['max_passkeys_reached', 'failure'],
15+
['max_identifiers_reached', 'support'],
1516
['kratos_unavailable', 'transient'],
1617
] as const
1718
).forEach(([code, handling]) => {

‎ui/hooks/identity/mfa/engine/errors.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const HANDLING: Record<MfaFlowErrorCode, MfaErrorHandling> = {
2828
rate_limited: 'cooldown',
2929

3030
max_passkeys_reached: 'failure',
31-
max_identifiers_reached: 'failure',
31+
// The profile has paired as many wallets as it can: only support can help.
32+
max_identifiers_reached: 'support',
3233
multi_primary_srp: 'support',
3334
// Removal only, outside the flow: the settings page shows its own error.
3435
cross_type_step_up_required: 'failure',

‎ui/pages/mfa/labels.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const ERROR_KEYS: Partial<Record<MfaFlowErrorCode, string>> = {
2020
otp_resend_cooldown: 'mfaErrorCooldown',
2121
rate_limited: 'mfaErrorCooldown',
2222
max_passkeys_reached: 'mfaErrorLimitReached',
23-
max_identifiers_reached: 'mfaErrorLimitReached',
2423
authentication_required: 'mfaErrorSignedOut',
2524
passkey_unsupported: 'mfaErrorUnsupported',
2625
flow_in_progress: 'mfaErrorFlowInProgress',
@@ -72,15 +71,19 @@ export const getSpecificErrorMessageKey = (
7271
* Errors whose failure screen has its own title and description, rather than
7372
* "Something went wrong" and the error's message.
7473
*/
74+
const SUPPORT_KEYS = {
75+
title: 'mfaFailureSupportTitle',
76+
description: 'mfaFailureSupportDescription',
77+
};
78+
79+
/* eslint-disable @typescript-eslint/naming-convention -- the server's codes */
7580
const FAILURE_KEYS: Partial<
7681
Record<MfaFlowErrorCode, { title: string; description: string }>
7782
> = {
78-
// eslint-disable-next-line @typescript-eslint/naming-convention -- the server's code
79-
multi_primary_srp: {
80-
title: 'mfaFailureSupportTitle',
81-
description: 'mfaFailureSupportDescription',
82-
},
83+
max_identifiers_reached: SUPPORT_KEYS,
84+
multi_primary_srp: SUPPORT_KEYS,
8385
};
86+
/* eslint-enable @typescript-eslint/naming-convention */
8487

8588
/**
8689
* The failure screen's message keys for an error.

‎ui/pages/mfa/steps/steps.test.tsx‎

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ describe('FailureStep', () => {
773773
<FailureStep
774774
{...buildState({
775775
name: 'failure',
776-
code: 'max_identifiers_reached',
776+
code: 'max_passkeys_reached',
777777
canRetry: false,
778778
})}
779779
reason={reason}
@@ -792,32 +792,35 @@ describe('FailureStep', () => {
792792
expect(onAction).toHaveBeenCalledWith({ type: 'dismiss' });
793793
});
794794

795-
it('sends an error only support can fix to support', () => {
796-
const onAction = jest.fn();
797-
render(
798-
<FailureStep
799-
{...buildState({
800-
name: 'failure',
801-
code: 'multi_primary_srp',
802-
canRetry: false,
803-
})}
804-
reason={reason}
805-
onAction={onAction}
806-
/>,
807-
);
795+
it.each(['multi_primary_srp', 'max_identifiers_reached'] as const)(
796+
'sends %s to support',
797+
(code) => {
798+
const onAction = jest.fn();
799+
render(
800+
<FailureStep
801+
{...buildState({
802+
name: 'failure',
803+
code,
804+
canRetry: false,
805+
})}
806+
reason={reason}
807+
onAction={onAction}
808+
/>,
809+
);
808810

809-
expect(
810-
screen.getByText(messages.mfaFailureSupportTitle.message),
811-
).toBeInTheDocument();
812-
fireEvent.click(screen.getByTestId(MfaFlowTestIds.PRIMARY_BUTTON));
813-
const supportLink = new URL(
814-
screen.getByTestId('support-modal').textContent ?? '',
815-
);
816-
expect(supportLink.searchParams.get('mfa_error')).toBe('multi_primary_srp');
811+
expect(
812+
screen.getByText(messages.mfaFailureSupportTitle.message),
813+
).toBeInTheDocument();
814+
fireEvent.click(screen.getByTestId(MfaFlowTestIds.PRIMARY_BUTTON));
815+
const supportLink = new URL(
816+
screen.getByTestId('support-modal').textContent ?? '',
817+
);
818+
expect(supportLink.searchParams.get('mfa_error')).toBe(code);
817819

818-
fireEvent.click(screen.getByTestId(MfaFlowTestIds.SECONDARY_BUTTON));
819-
expect(onAction).toHaveBeenCalledWith({ type: 'dismiss' });
820-
});
820+
fireEvent.click(screen.getByTestId(MfaFlowTestIds.SECONDARY_BUTTON));
821+
expect(onAction).toHaveBeenCalledWith({ type: 'dismiss' });
822+
},
823+
);
821824
});
822825

823826
describe('TotpSetupStep', () => {

0 commit comments

Comments
 (0)