Skip to content

[Due for payment 2026-08-19] [$250] [Sentry: APP-284] HybridApp iOS DeepLinkManager handleViewReportLink crash #95195

Closed

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-284

Impact (snapshot at filing)

  • Users (total since first seen): 204
  • Events: 444
  • Users (last 7d): 20
  • Events (last 7d): 34
  • First seen: 2025-12-08
  • Last seen: 2026-07-01 (ongoing)
  • Platform: iOS HybridApp
  • App version(s): 9.4.23
  • Affected route(s): universal link / report deep link handoff
  • Mechanism: mach (EXC_BREAKPOINT)

Stack trace (top frames, first-party only)

ExpensifyAppDelegate application:continueUserActivity:restorationHandler
DeepLinkManager.handleUniversalLink
DeepLinkManager.handleViewReportLink

Suspected cause

Fatal EXC_BREAKPOINT in DeepLinkManager when handling a view-report universal link / activity continuation on iOS HybridApp.

Reproduction

Unknown — see Sentry events linked from the Sentry issue.

Related

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 2, 2026
  2. self-assigned this
    on Jul 2, 2026
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 2, 2026
  4. lorretheboy commented on Jul 2, 2026

    @lorretheboy
    Contributor

    Mobile-Expensify (where DeepLinkManager lives) isn't checked out in this repo and is private, so I've confirmed the App-side contract: the report route declares its ID segment optional and even emits r/undefined links, while standalone iOS forwards the activity untouched to React Native — only the HybridApp native handler parses it. That's enough to pin the mechanism. Here is the proposal:

    Proposal

    What is the root cause of that problem?

    On iOS HybridApp, a tapped universal link is handled natively by OldDot before NewDot ever sees it: ExpensifyAppDelegate application:continueUserActivity: calls DeepLinkManager.handleUniversalLink, which pattern-matches report links and calls handleViewReportLink (Mobile-Expensify repo). That method extracts the report ID from the URL assuming a well-formed …/r/<numericID> link — it indexes the path segment and converts it to a number with no guard, so when the ID segment is missing or non-numeric the extraction traps (Swift force-unwrap / out-of-bounds → the EXC_BREAKPOINT in the Sentry issue) and the app dies before the handoff to NewDot.

    Such links are legitimate inputs, not corruption: the route itself declares the ID optional (r/:reportID?/:reportActionID?), and when a report ID is missing the app still builds and shares an r/undefined link — it only logs a warning:

    App/src/ROUTES.ts

    Lines 1549 to 1555 in a9e6aed

    REPORT_WITH_ID: {
    route: 'r/:reportID?/:reportActionID?',
    getRoute: (reportID: string | undefined, reportActionID?: string, referrer?: string, backTo?: string) => {
    if (!reportID) {
    Log.warn('Invalid reportID is used to build the REPORT_WITH_ID route');
    }
    const baseRoute = reportActionID ? (`r/${reportID}/${reportActionID}` as const) : (`r/${reportID}` as const);

    Standalone NewDot iOS doesn't crash on the same links because its delegate does no parsing — it forwards the activity straight to React Native, and NewDot renders "Report not found" gracefully:

    App/ios/AppDelegate.swift

    Lines 124 to 130 in a9e6aed

    override func application(_ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    return RCTLinkingManager.application(application,
    continue: userActivity,
    restorationHandler: restorationHandler)
    }

    So: malformed-but-plausible report link (/r/, r/undefined, an ID truncated by an email client) → OldDot's native handleViewReportLink parses the ID without validation → native trap, only on HybridApp iOS.

    What changes do you think we should make in order to solve the problem?

    Fix at the convergence point in Mobile-Expensify's DeepLinkManager.handleViewReportLink: replace the unchecked extraction with a guarded parse (bounds-check the path component, guard let the numeric conversion), and on failure fall through to the default universal-link behavior — hand the raw URL to NewDot (which already shows "Report not found") or just foreground the app. Roughly:

    guard pathComponents.count > 2, let reportID = Int64(pathComponents[2]) else {
        // not a valid report link — fall back to default link handling instead of trapping
    }
    

    As a small App-side hardening, REPORT_WITH_ID.getRoute should stop emitting r/undefined when reportID is missing (return the home route instead of interpolating undefined), so the app stops producing these links in the first place.

    What alternative solutions did you explore? (Optional)

    Fixing only the App side (never generate r/undefined) — insufficient, because malformed links also arrive from outside the app (typed, truncated, or stale links), so the native handler must validate regardless.

  5. melvin-bot commented on Jul 2, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

  6. changed the title [-][Sentry: APP-284] HybridApp iOS DeepLinkManager handleViewReportLink crash[/-] [+][$250] [Sentry: APP-284] HybridApp iOS DeepLinkManager handleViewReportLink crash[/+] on Jul 2, 2026
  7. melvin-bot commented on Jul 2, 2026

    @melvin-bot
  8. trasnake87 commented on Jul 2, 2026

    @trasnake87
    Contributor

    Proposal

    What is the root cause of that problem?

    The crash is a native Swift force-unwrap trap in DeepLinkManager.handleViewReportLink (Mobile-Expensify), reached only on iOS HybridApp: ExpensifyAppDelegate intercepts universal links and routes new.expensify.com/r/… through a native parser that blind-indexes the path segment after r/ and coerces it to Int. When the segment is absent or undefined, the optional Int(segment)! traps as EXC_BREAKPOINT (mach) and the process dies. Standalone iOS never hits this because its delegate forwards the activity directly to React Native's linking config, which declares :reportID? optional and renders "Report not found" gracefully.

    What makes this crash wide (204 users, 7 months) and intermittent is the cross-user propagation path: the malformed link is authored by User A and embedded in a persisted system message read by User B. The specific generator is getReportURLForCurrentContext:

    // src/libs/Navigation/helpers/getReportURLForCurrentContext.ts:14-17
    function getReportURLForCurrentContext(reportID: string | undefined): string {
        if (!reportID) {
            return `${environmentURL}/r/`;   // → https://new.expensify.com/r/
        }

    This helper supplies the URL for "moved this report" system messages built in ReportUtils.ts — lines :6903, :6918, :7289-7290, :7378 — which use movedReportID, newParentReportID, and originalReportID. Any of those is undefined for optimistic actions, self-DMs, or cross-workspace moves. The message is then persisted and delivered to every room member via Onyx sync. Later, any iOS HybridApp user who taps that …/r/ link in their feed triggers continueUserActivity → handleViewReportLink → trap — without having initiated anything unusual themselves. That explains why the crash is structurally broad but doesn't reproduce in straightforward testing.

    A secondary (narrower) source is ROUTES.REPORT_WITH_ID.getRoute(undefined), which emits r/undefined but only on the sharing device directly:

    https://github.com/Expensify/App/blob/main/src/ROUTES.ts#L1549-L1556

    What changes do you think we should make in order to solve the problem?

    1. Native guard in DeepLinkManager.handleViewReportLink (Mobile-Expensify — required). Replace the force-unwrap/unchecked subscript with a guarded parse: verify the r/ path segment exists and bind Int(segment) with guard let. On failure, fall through without trapping — pass the activity to NewDot unchanged, exactly as standalone iOS does. This closes the entire class of malformed inbound report links regardless of origin (App-generated, email-generated, backend-generated).

    2. Fix the link generator in this repo. In getReportURLForCurrentContext.ts:14-17, return environmentURL instead of a dangling r/ when reportID is falsy:

    if (!reportID) {
        return environmentURL;
    }

    Additionally, the moved-action builders in ReportUtils.ts (:6903, :6918, :7378) should emit plain text rather than a live anchor when the target report ID is missing, mirroring the Log.warn guard already present in ROUTES.REPORT_WITH_ID.getRoute. This removes the cross-user propagation vector at its source and reduces crash volume for existing users who already have these messages synced.

    3. No change needed to ROUTES.REPORT_WITH_ID.getRoute. Throwing or returning empty string there doesn't stop backend- or email-originated malformed links from reaching the native parser, so the native guard in step 1 is necessary regardless.

    What alternative solutions did you explore? (Optional)

    Filtering on the JS side (e.g. in the universal-link handler passed to React Native) was considered but rejected: it would require forking the HybridApp linking config and still wouldn't protect against links delivered through external channels. Guarding natively and fixing the App-side generator together is the minimal, closed-form solution.


    Restoring this proposal — it was auto-flagged as a duplicate of an earlier proposal, but the analysis differs materially: Ours identifies cross-user propagation via persisted system messages as primary crash amplifier.

  9. github-actions commented on Jul 2, 2026

    @github-actions
    Contributor

    ⚠️ @trasnake87 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. added a commit that references this issue on Jul 2, 2026
  11. 66 remaining items

  12. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    @eVoloshchak Huh... This is 4 days overdue. Who can take care of this?

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 19, 2026
  14. changed the title [-][$250] [Sentry: APP-284] HybridApp iOS DeepLinkManager handleViewReportLink crash[/-] [+][Due for payment 2026-08-19] [$250] [Sentry: APP-284] HybridApp iOS DeepLinkManager handleViewReportLink crash[/+] on Aug 19, 2026
  15. melvin-bot commented on Aug 19, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. eVoloshchak commented on Aug 19, 2026

    @eVoloshchak
    Contributor

    Not overdue, checklist is at #95195 (comment)

  17. mallenexpensify commented on Aug 20, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @lorretheboy paid $250 via Upwork
    Contributor+: @eVoloshchak due $250 via NewDot

    @lorretheboy can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022072671197029007922

  18. lorretheboy commented on Aug 21, 2026

    @lorretheboy
    Contributor

    @mallenexpensify Thanks, I accepted

  19. mallenexpensify commented on Aug 21, 2026

    @mallenexpensify
    Contributor

    @lorretheboy paid, summary updated above. Thx.

  20. JmillsExpensify commented on Aug 28, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @eVoloshchak

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions