fix(mobile): redact a malformed openLink's query from its error
Merged
DE
2mo ago+33+33+01234567890123456789-3-3-0123456789
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 throughlinkLabel, 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.assertAppIdin the same file already never echoes the link at all, for this reason, andlinkLabelhas been the shared way to show a link safely sincedevice.openLinklanded. 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 namingmyapp://orders/42andhttps://example.com/verify. docs/reference/mobile.mdxstates that a string which does not parse as an absolute URL isINVALID_ARGUMENTand 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/mobilefromupstream/mainand from this branch, then called the compiledlinkTargetfrom eachdist/links.jswith the same input:
| main | this branch |
|---|---|
got "not-a-url?token=s3cret-onetime" | got "not-a-url" |
- New unit test in
packages/mobile/tests/unit/links.test.tscovers three malformed inputs whose query holds a token. It fails on main and passes here, and the existinglinkscases, including the ones pinning thatassertAppIdnever echoes a link, still pass. pnpm --filter @e2e-dev/mobile run buildandrun typecheckpass, andoxlinton 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 testfor the mobile package, because this machine reports 55 failures undercaptured-snapshots,engine, andprovider(Windows path and line-ending expectations) that reproduce identically on unmodifiedupstream/main. Thelinksfile this touches passes in full.