-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(runway): cherry-pick fix(ramp): cp-7.60.0 fix phone already registered error detection in BasicInfo form #23333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(runway): cherry-pick fix(ramp): cp-7.60.0 fix phone already registered error detection in BasicInfo form #23333
Conversation
…istered error detection in BasicInfo form (#23299) ## **Description** Fixed error handling in BasicInfo component to correctly access error codes from Axios error responses. The code was previously trying to access `error.error.errorCode` but Axios errors have the structure `error.response.data.error.errorCode`, which prevented error code 2020 (phone already registered) from being detected correctly. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: #23302 ## **Manual testing steps** ```gherkin Feature: BasicInfo form error handling Scenario: user submits form with already registered phone number Given I am on the BasicInfo screen with valid form data When I submit the form with a phone number that is already registered Then I should see an error message indicating the phone is already registered And I should see a "Log in with email" button And clicking the logout button should navigate to the email entry screen ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="333" height="720" alt="image" src="https://github.com/user-attachments/assets/0a01a7be-e4bb-496c-8396-e77d5785b668" /> ### **After** https://github.com/user-attachments/assets/e8acba92-1032-4f49-a5bd-84a605bda71f ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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] > Fixes BasicInfo to read Axios error response for code 2020, format the email-based message, and expose a logout-to-email flow; updates tests to use AxiosError and cover these behaviors. > > - **UI (Deposit BasicInfo)**: > - Parse Axios errors via `response.data.error` to detect Transak `errorCode` `2020` and set `isPhoneRegisteredError`. > - Extract email from error message to show localized `phone_already_registered` banner text. > - Show "Log in with email" action on the error banner and navigate to `Routes.DEPOSIT.ENTER_EMAIL`; gracefully handle logout failures. > - Minor: add `AxiosError` typing and default fallback message. > - **Tests** (`BasicInfo.test.tsx`): > - Replace custom errors with `AxiosError` shaped responses; add/import Axios types. > - Verify formatted message, presence/absence of logout button by error type, navigation on logout, and error handling when logout fails. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0961bb6. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsFallback: AI analysis did not complete successfully. Running all tests. |
| let errorMessage = errorMessageText; | ||
| if (isPhoneError && errorMessageText) { | ||
| // Extract email from message for error code 2020 (phone already registered) | ||
| const emailMatch = errorMessageText.match(/[\w*]+@[\w*]+(?:\.[\w*]+)*/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Email extraction uses wrong error message source
When error code 2020 is detected, the code attempts to extract the email from errorMessageText (derived from submissionError.message), but the actual detailed message containing the email is in apiError.message. In real Axios errors, submissionError.message typically contains generic text like "Request failed with status code 400" rather than the API's detailed error message, preventing email extraction from working correctly in production.
| email, | ||
| }, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing fallback for failed email extraction
When error code 2020 is detected but email extraction fails (no email found in the message), the code no longer falls back to showing the API error message. The old code had errorMessage = email ? strings(...) : errorWithCode.error.message, providing the full API message as fallback. The new code only updates errorMessage when an email is found, leaving it as the generic Axios error message otherwise, degrading the user experience when email extraction fails.
|
|
No release label on PR. Adding release label release-7.60.0 on PR, as PR was cherry-picked in branch 7.60.0. |



Description
Fixed error handling in BasicInfo component to correctly access error
codes from Axios error responses. The code was previously trying to
access
error.error.errorCodebut Axios errors have the structureerror.response.data.error.errorCode, which prevented error code 2020(phone already registered) from being detected correctly.
Changelog
CHANGELOG entry: null
Related issues
Fixes: #23302
Manual testing steps
Screenshots/Recordings
Before
After
Screen_Recording_20251125_193533_MetaMask.mp4
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Fixes BasicInfo to read Transak error code 2020 from Axios responses, show a formatted email message with a logout action, and navigate to email entry; tests updated to use AxiosError.
BasicInfo.tsx):response.data.errorto detect TransakerrorCode2020.isPhoneRegisteredErrorto render a "Log in with email" action; on press, calllogoutFromProvider(false)and navigate toRoutes.DEPOSIT.ENTER_EMAIL.AxiosError.BasicInfo.test.tsx):AxiosErrorwithresponse.data.error.errorCode2020.Written by Cursor Bugbot for commit 46aa1dd. This will update automatically on new commits. Configure here.
3807955