Fix: prevent dynamic route crash when "action" query param exists in both base path and suffix - #98949
Fix: prevent dynamic route crash when "action" query param exists in both base path and suffix#98949MelvinBot wants to merge 1 commit into
Conversation
…param Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
✅ Android test passedRan the PR's testing steps on standalone Android NewDot (branch Steps performed
Screenshots and recording attached below. |
|
Explanation of Change
createDynamicRoutebuilds a route by concatenating the current active route (base) with a dynamic suffix and merging their query strings viamergeQueryStrings. When the same query key appeared in both,mergeQueryStringsthrew a fatal error instead of navigating.On the money-request Tag step this collision is reachable through normal use: the tag row's
onPresscallscreateDynamicRoutewith no explicitbasePath, so it falls back toNavigation.getActiveRoute()(which keeps the current?action=…query string), while theexpense-tagsuffix always carries its ownactionparam. When the active route already carries?action=…, both base and suffix containaction, the guard throws, and — because the throw fires inside anonPresshandler on iOS Hermes — it crashes the app (Sentry APP-JSV / APP-JPQ,level: fatal).The guard was treating a normal, recoverable navigation as an unrecoverable invariant violation. This change makes
mergeQueryStringsnon-fatal: when a key exists in both, the suffix value wins (it is the intended destination of the tap —params.setalready does this) and a differing value is logged viaLog.warnfor visibility instead of throwing. This mirrors the recoverable-navigation approach already used for the same util in #97849.Added/updated unit tests in
tests/navigation/createDynamicRouteTests.tsto cover the collision case (suffix wins + warn logged) and the same-value case (no warn).Fixed Issues
$ #98792
PROPOSAL: #98792 (comment)
Tests
/search/view/:reportID/expense-report) and enter a money-request flow that lands on the Tag step on a route already carrying an?action=…query param.Offline tests
Same as tests.
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari