Skip to content

fix: try fixing X deeplinks by adding $deeplink_path param [GE-139] cp-7.69.0#27139

Merged
baptiste-marchand merged 5 commits into
mainfrom
fix/x-deeplinks-fix-trial
Mar 10, 2026
Merged

fix: try fixing X deeplinks by adding $deeplink_path param [GE-139] cp-7.69.0#27139
baptiste-marchand merged 5 commits into
mainfrom
fix/x-deeplinks-fix-trial

Conversation

@baptiste-marchand
Copy link
Copy Markdown
Contributor

@baptiste-marchand baptiste-marchand commented Mar 6, 2026

Description

Fix branch deeplinks not working with the X (Twitter) app by adding a $deeplink_path param in branch.io and consuming it in MetaMask Mobile.

Context

What we found

  1. No resolved URI from the SDK
  • The Branch iOS SDK (and react-native-branch) give us:
  • The SDK does not build a custom deeplink URI (e.g. metamask://swap) from link data; it only returns the params. So we have to do routing ourselves.
  1. Implemented fix:
  • Added a $deeplink_path in Branch deeplinks (this must be added to every existing and future deeplinks that we want to post on X)
  • Read it from the params and build our deeplink ourselves (e.g. metamask://${params.$deeplink_path}) and then route inside the app.

Changelog

CHANGELOG entry: Fixed a bug that was causing deeplinks opened from X app to fail

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/GE-139
Fixes: #27140

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

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

Medium Risk
Touches deeplink routing/host allowlists and Branch handling on app start, which can affect navigation from external links, but the change is narrowly scoped and covered by new unit tests.

Overview
Fixes Branch short-link universal links (notably from X on iOS) by introducing rewriteBranchUri, which converts metamask-alternate.app.link/<id> URLs into https://link.metamask.io/<$deeplink_path> while preserving query params.

DeeplinkManager.start() now applies this rewrite for both cold-start Branch params (~referring_link) and branch.subscribe events, replacing the prior getLatestReferringParams fallback logic.

Adds MM_UNIVERSAL_LINK_HOST_ALTERNATE (metamask-alternate.app.link) and includes it in universal-link host validation (handleUniversalLink) and MetaMask-host detection (util/deeplinks), with new tests covering rewrite and routing behavior.

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

@baptiste-marchand baptiste-marchand requested a review from a team as a code owner March 6, 2026 16:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

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.

Comment thread app/core/DeeplinkManager/DeeplinkManager.ts Outdated
@Montoya
Copy link
Copy Markdown
Contributor

Montoya commented Mar 6, 2026

This fixes #27140

Comment thread app/core/DeeplinkManager/DeeplinkManager.ts Outdated
Comment thread app/core/DeeplinkManager/DeeplinkManager.ts Outdated
Cal-L
Cal-L previously approved these changes Mar 9, 2026
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 9, 2026
@baptiste-marchand baptiste-marchand changed the title fix: try fixing X deeplinks by adding fix: try fixing X deeplinks by adding [GE-139] Mar 9, 2026
@github-actions github-actions Bot added size-M and removed size-S labels Mar 10, 2026
Comment thread app/core/DeeplinkManager/DeeplinkManager.ts
): string | undefined {
if (!uri || !params?.['+clicked_branch_link']) return uri;
const rawPath = params.$deeplink_path;
if (typeof rawPath !== 'string') return uri;
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.

Cold start incorrectly processes unrewritten ~referring_link URI

High Severity

rewriteBranchUri returns the original uri (truthy) when rewriting conditions aren't met (e.g., +clicked_branch_link is false or $deeplink_path is absent). The cold start caller checks if (rewritten) as a gate, so any truthy ~referring_link bypasses the +non_branch_link fallback. This causes the app to process a raw, unresolvable Branch short link (leading to a 404) or a stale ~referring_link from a prior session. The function needs to return undefined instead of uri when it doesn't actually rewrite.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread app/core/DeeplinkManager/DeeplinkManager.ts
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Code looks good. Let's revert the version changes

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/core/DeeplinkManager/util/deeplinks/index.ts
@baptiste-marchand baptiste-marchand force-pushed the fix/x-deeplinks-fix-trial branch from d85ee5b to de4e3dc Compare March 10, 2026 13:03
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations, SmokeRamps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR modifies deep link handling in DeeplinkManager, adds rewrite logic for Branch short links, and expands supported universal link hosts (metamask-alternate.app.link). Deep links are critical entry points into in-app flows, especially swap and buy flows that are commonly triggered via Branch/universal links.

Key impacts:

  • Rewrites Branch short links using $deeplink_path to link.metamask.io/ while preserving query params.
  • Alters cold start behavior for Branch links (getLatestReferringParams flow).
  • Changes subscribe callback handling to use rewritten URI.
  • Expands supported universal link domains.

These changes can directly affect:

  • Swap deep links (e.g., /swap with amount/token params) → SmokeTrade.
  • Any flow that results in transaction confirmations from deep links (swap/bridge) → SmokeConfirmations (required when selecting SmokeTrade).
  • Buy/on-ramp deep links triggered via universal links → SmokeRamps (explicitly covers deep link navigation into buy flows).

No changes affect controllers, Engine, account management, network management, Snaps, or multi-chain provider logic. Therefore, broader tags like SmokeWalletPlatform, SmokeAccounts, SmokeNetworkAbstractions, etc., are not required.

Given the centrality of deep links to growth and transaction flows, this is medium risk: incorrect rewriting could silently break swap or buy entry points. Running the focused trade + confirmations + ramps suites provides strong coverage with minimal over-testing.

Performance Test Selection:
Changes are limited to deep link parsing and URI rewriting logic. No UI rendering, state management, controller initialization, or performance-sensitive flows (startup timing, account list, swaps execution performance) were modified. Therefore, no performance tests are required.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

@Montoya Montoya added this pull request to the merge queue Mar 10, 2026
@Montoya Montoya removed this pull request from the merge queue due to a manual request Mar 10, 2026
@baptiste-marchand baptiste-marchand added this pull request to the merge queue Mar 10, 2026
@baptiste-marchand baptiste-marchand removed this pull request from the merge queue due to a manual request Mar 10, 2026
@baptiste-marchand baptiste-marchand changed the title fix: try fixing X deeplinks by adding [GE-139] fix: try fixing X deeplinks by adding [GE-139] cp-7.69.0 Mar 10, 2026
@baptiste-marchand baptiste-marchand added this pull request to the merge queue Mar 10, 2026
Merged via the queue into main with commit 0696104 Mar 10, 2026
117 checks passed
@baptiste-marchand baptiste-marchand deleted the fix/x-deeplinks-fix-trial branch March 10, 2026 23:26
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 10, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 10, 2026
@baptiste-marchand baptiste-marchand changed the title fix: try fixing X deeplinks by adding [GE-139] cp-7.69.0 fix: try fixing X deeplinks by adding $deeplink_path param [GE-139] cp-7.69.0 Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-M team-engagement

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Bug]: Deeplinks not working from X (twitter) in app browser

5 participants