Skip to content

fix(scan): reject unreachable manual URLs and soften transport errors - #3326

Open
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixscan-validate-manual-preview-urls-56a607
Open

posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixscan-validate-manual-preview-urls-56a607

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary (AI generated)

Fixes two failures on the mobile scan screen (src/pages/scan.vue), plus a
resilience gap on the preview payload route.

  • Reject unreachable manual URLs before submit. The manual field prepended
    https:// to any input, so a single word with no dot ("capago" ->
    https://capago) parsed fine and went straight to the native downloader,
    which failed with a raw platform DNS error. Submission now requires a dotted
    domain, an IP literal, or an explicit local host (isReachableHttpUrl).
  • Plain-language transport errors. Network failures no longer echo the raw
    platform string ("A server with the specified hostname could not be found").
    They map to That address could not be reached. Check the link and your connection, then try again. The raw error is still kept in the debug log.
  • Payload route survives a DB hiccup. files/preview.ts now passes the
    underlying database error as the simpleError cause, so onError classifies
    a transient Postgres timeout as a retryable 503 upstream_unavailable
    instead of a bare 500 (or a misleading 400 bundle_not_found).

The pure URL/error helpers moved into src/services/previewLinks.ts so they can
be unit-tested.

Test plan (AI generated)

  • bunx vitest run tests/preview-links.unit.test.ts tests/preview-payload-db-error.unit.test.ts (added):
    • bare host (https://capago) is rejected; dotted domains, IPs, localhost,
      and [::1] are accepted.
    • manual-URL normalization keeps explicit schemes and assumes https otherwise.
    • native/browser transport strings are detected; unrelated errors are not.
    • a transient DB error on the payload lookup is threaded as the error cause and
      classified transient (drives the 503); a genuine missing bundle stays a
      non-transient 400.
  • bun typecheck and eslint on the touched files pass.

Screenshots (AI generated)

Not captured. The affected states are native-download failure paths (iOS
updater / fetch transport errors) that cannot be reproduced in the web preview.
The change is input validation plus error copy; behavior is covered by the unit
tests above.

Checklist

  • My code follows the code style of this project and passes lint on the
    touched files.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change has adequate test coverage (unit tests added).
  • I have tested my code manually (verified via unit tests; native download
    flow not reproducible here).

Created with PostHog Desktop from this inbox report.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

@posthog-eu
posthog-eu Bot deployed to deepsec-pr September 14, 2026 11:55 Active
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 66b764d0-c482-4f3a-a985-7214e4289213

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 82.22%

⚡ 1 improved benchmark
✅ 42 untouched benchmarks
⏩ 2 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ /updates manifest response with metadata 255.5 µs 140.2 µs +82.22%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing posthog-self-driving/fixscan-validate-manual-preview-urls-56a607 (d20b41e) with main (ea1a1ed)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@posthog-eu
posthog-eu Bot marked this pull request as ready for review September 14, 2026 12:22
@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

@coderabbitai review

@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

@cursor review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 16:57 Active
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

@coderabbitai full review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 17:19 Active
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

@coderabbitai review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 17:45 Active
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

@coderabbitai help

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 17:52 Active
@riderx

riderx commented Sep 23, 2026

Copy link
Copy Markdown
Member

@coderabbitai review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 18:01 Active
@riderx

riderx commented Sep 23, 2026

Copy link
Copy Markdown
Member

@coderabbitai full review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 18:25 Active
@riderx

riderx commented Sep 23, 2026

Copy link
Copy Markdown
Member

@coderabbitai full review

@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 18:42 Active
@riderx

riderx commented Sep 23, 2026

Copy link
Copy Markdown
Member

@coderabbitai full review

coderabbit-trigger:af08a765ffa515ef4ac82848659991210f47104e

@TorichanCapgo

Copy link
Copy Markdown
Contributor

@coderabbitai full review

Please review current HEAD. Ignore prior CI-only commits that only tipped CodeRabbit; a cleanup to product-only diff is in flight if still present.

The manual URL field prepended `https://` to any input and accepted it as
long as `new URL()` parsed, so a single word with no dot (for example
"capago" -> "https://capago") reached the native downloader and failed with
a raw iOS message ("A server with the specified hostname could not be
found").

- Reject an http(s) host with no dot, IP literal, or explicit local host
  before submitting or downloading, via `isReachableHttpUrl`.
- Map transport failures to plain guidance ("That address could not be
  reached...") instead of echoing the raw platform error, via
  `isNetworkReachabilityError`; the raw error stays in the debug log.
- Preview payload route: pass the underlying DB error as the `simpleError`
  cause so `onError` classifies a transient Postgres hiccup as a retryable
  503 instead of a bare 500 / misleading 400.

Extracted the pure URL helpers into `previewLinks.ts` for unit coverage.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor
cursor Bot force-pushed the posthog-self-driving/fixscan-validate-manual-preview-urls-56a607 branch from af08a76 to d20b41e Compare September 23, 2026 18:53
@cursor
cursor Bot deployed to deepsec-pr September 23, 2026 18:53 Active
@sonarqubecloud

Copy link
Copy Markdown

@TorichanCapgo

Copy link
Copy Markdown
Contributor

@coderabbitai full review

1 similar comment
@TorichanCapgo

Copy link
Copy Markdown
Contributor

@coderabbitai full review

This branch was successfully deployed

1 active deployment
deepsec-pr — d20b41e9 Deployed Sep 23, 2026 by cursor[bot] via Scan PR changes #7767
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants