Skip to content

[codex] Structure browser target resolution errors - #3327

Merged
juliusmarminge merged 2 commits into
codex/redact-dpop-request-targetfrom
codex/browser-target-resolution-errors
Jun 20, 2026
Merged

[codex] Structure browser target resolution errors#3327
juliusmarminge merged 2 commits into
codex/redact-dpop-request-targetfrom
codex/browser-target-resolution-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • replace generic browser target failures with schema-tagged errors carrying environment and host context
  • preserve the native URL parsing cause alongside the invalid environment base URL
  • add focused coverage for disconnected, public-host, and malformed connection cases

Verification

  • vp test apps/web/src/browser/browserTargetResolver.test.ts
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Note

Low Risk
Localized resolver and shared URL-redaction helpers; behavior is unchanged aside from error shape and safer diagnostics, with no auth or data-path changes in this diff.

Overview
resolveBrowserNavigationTarget now throws three Effect Schema.TaggedErrorClass types instead of generic Errors: disconnected environment, invalid environment HTTP base URL (with native parse cause), and non–private-network host (with environmentId and hostname).

Invalid-base-URL failures use new getUrlDiagnostics (@t3tools/shared/urlDiagnostics) so errors expose only input length and optional protocol/hostname—tests assert messages and shapes never leak credentials or full URLs.

Shared redactDpopRequestTarget strips userinfo, query, and fragment from URLs for safe logging (invalid input → "<invalid-url>"), with tests only in this PR.

Breaking for callers: anything that matched generic error strings must handle tagged errors by _tag / type instead.

Reviewed by Cursor Bugbot for commit c7db911. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Replace generic errors with structured tagged error classes in resolveBrowserNavigationTarget

  • Introduces three new tagged error classes in browserTargetResolver.ts: BrowserTargetEnvironmentDisconnectedError, BrowserTargetEnvironmentUrlInvalidError, and BrowserTargetPrivateNetworkRequiredError, each with structured properties and computed messages.
  • BrowserTargetEnvironmentUrlInvalidError uses a new getUrlDiagnostics helper (in packages/shared/src/urlDiagnostics.ts) to expose only non-sensitive diagnostics (input length, protocol, hostname) when a URL cannot be parsed.
  • Adds redactDpopRequestTarget to packages/shared/src/dpop.ts to produce redacted DPoP request targets without leaking user info, query, or fragment.
  • Behavioral Change: callers catching errors from resolveBrowserNavigationTarget will now receive typed tagged errors instead of generic Error instances.

Macroscope summarized c7db911.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a01d1ce4-2664-439d-9186-bdab227bbd53

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/browser-target-resolution-errors

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR refactors error handling to use structured Effect TaggedErrorClass types instead of plain Error objects. The error conditions and messages remain identical; only the structure is enhanced for better typing and diagnostics. Low-risk mechanical change with comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

juliusmarminge and others added 2 commits June 20, 2026 09:31
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/browser-target-resolution-errors branch from a18ef81 to c7db911 Compare June 20, 2026 16:45
@juliusmarminge
juliusmarminge changed the base branch from main to codex/redact-dpop-request-target June 20, 2026 16:45
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 16:45

Dismissing prior approval to re-evaluate c7db911

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
@juliusmarminge
juliusmarminge merged commit c5bc774 into codex/redact-dpop-request-target Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/browser-target-resolution-errors branch June 20, 2026 18:00
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 21, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 21, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 21, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge added a commit that referenced this pull request Jun 21, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant