Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Nov 26, 2025

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

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

Before

image

After

Screen_Recording_20251125_193533_MetaMask.mp4

Pre-merge author checklist

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.

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 (BasicInfo.tsx):
    • Parse Axios error via response.data.error to detect Transak errorCode 2020.
    • Extract email from error message and display localized "phone already registered" text.
    • Toggle isPhoneRegisteredError to render a "Log in with email" action; on press, call logoutFromProvider(false) and navigate to Routes.DEPOSIT.ENTER_EMAIL.
    • Preserve error visibility and log on logout failure; minor import of AxiosError.
  • Tests (BasicInfo.test.tsx):
    • Update error mocks to use AxiosError with response.data.error.errorCode 2020.
    • Assert formatted message, presence/absence of logout button, logout flow navigation, and graceful handling of logout errors.

Written by Cursor Bugbot for commit 46aa1dd. This will update automatically on new commits. Configure here.

3807955

…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 -->
@runway-github runway-github bot requested a review from a team as a code owner November 26, 2025 17:49
@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Nov 26, 2025
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

let errorMessage = errorMessageText;
if (isPhoneError && errorMessageText) {
// Extract email from message for error code 2020 (phone already registered)
const emailMatch = errorMessageText.match(/[\w*]+@[\w*]+(?:\.[\w*]+)*/);
Copy link

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.

Fix in Cursor Fix in Web

email,
},
);
}
Copy link

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.

Fix in Cursor Fix in Web

@joaoloureirop joaoloureirop enabled auto-merge (squash) November 26, 2025 17:54
@sonarqubecloud
Copy link

@joaoloureirop joaoloureirop merged commit 9e486a0 into release/7.60.0 Nov 26, 2025
201 of 211 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.60.0-1764179350 branch November 26, 2025 20:09
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 26, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.60.0 on PR, as PR was cherry-picked in branch 7.60.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.60.0 Issue or pull request that will be included in release 7.60.0 team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants