fix(mobile): redact a malformed openLink's query from its error

Merged
DE
2mo ago
+33-3

device.openLink builds its INVALID_ARGUMENT message from the raw input, so a malformed link still echoes whatever query it arrived with. A magic link carries its one-time token there, and a link that fails to parse is exactly the one nobody has checked yet, so that message lands in logs, the report, and CI output with the token intact.

What changed

  • linkTarget (packages/mobile/src/links.ts:43) now names the input through linkLabel, the helper that already cuts a link before its query and fragment for the step label and the report, so the message keeps the useful part (got "not-a-url") and drops the part that can hold a token.
  • assertAppId in the same file already never echoes the link at all, for this reason, and linkLabel has been the shared way to show a link safely since device.openLink landed. This brings the one remaining message in the file to that standard rather than adding a second rule.
  • The malformed case is unchanged otherwise: still INVALID_ARGUMENT, still the same guidance naming myapp://orders/42 and https://example.com/verify.
  • docs/reference/mobile.mdx states that a string which does not parse as an absolute URL is INVALID_ARGUMENT and that its message cuts the query and fragment, next to the existing line about the report doing the same.
  • Patch changeset for @e2e-dev/mobile.
linkTarget('myapp://orders/42?ref=mail');   // parses, query kept for the app
linkTarget('not-a-url?token=s3cret');       // INVALID_ARGUMENT, got "not-a-url"

Verified

Ran it locally: yes

  • Built @e2e-dev/mobile from upstream/main and from this branch, then called the compiled linkTarget from each dist/links.js with the same input:
mainthis branch
got "not-a-url?token=s3cret-onetime"got "not-a-url"
  • New unit test in packages/mobile/tests/unit/links.test.ts covers three malformed inputs whose query holds a token. It fails on main and passes here, and the existing links cases, including the ones pinning that assertAppId never echoes a link, still pass.
  • pnpm --filter @e2e-dev/mobile run build and run typecheck pass, and oxlint on the two changed files reports nothing.
  • pnpm docs:check-errors, pnpm check:peer-ranges, and the docs example and package-manager checks pass.
  • Not run here: the whole pnpm test for the mobile package, because this machine reports 55 failures under captured-snapshots, engine, and provider (Windows path and line-ending expectations) that reproduce identically on unmodified upstream/main. The links file this touches passes in full.