Skip to content

[codex] Structure relay environment connector errors#3331

Merged
juliusmarminge merged 4 commits into
codex/redact-dpop-request-targetfrom
codex/relay-environment-mint-errors
Jun 20, 2026
Merged

[codex] Structure relay environment connector errors#3331
juliusmarminge merged 4 commits into
codex/redact-dpop-request-targetfrom
codex/relay-environment-mint-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • attach user, endpoint, device, operation, and request-stage context to connector failures
  • preserve the real JWT/schema verification failure as the invalid-response cause
  • replace boolean response validation with constrained diagnostic reasons while keeping one generic service error

Validation

  • vp test infra/relay/src/environments/EnvironmentConnector.test.ts --no-cache
  • vp check
  • vp run typecheck
  • vpr typecheck

Overlap audit


Note

Medium Risk
Changes authentication-adjacent connect/mint error shapes and observability; consumers matching on old fields or message strings must update, but wire protocol behavior is largely unchanged aside from richer failures.

Overview
Relay EnvironmentConnector mint/health failures now expose structured tagged errors instead of sparse booleans and raw endpoint strings.

EnvironmentMintRequestFailed, EnvironmentMintResponseInvalid, and EnvironmentMintRequestTimedOut gain userId, optional deviceId, request stage or validation reason, and redacted httpBaseUrl fields (length, protocol, hostname) via getUrlDiagnostics and fromEndpoint helpers. JWT verification paths return discriminated outcomes so invalid responses carry reasons like proof_verification_failed and optional underlying cause; request failures are attributed to stages such as send_request.

Telemetry and logs for managed-endpoint resolution and health warnings record the same redacted URL diagnostics rather than full URLs, reducing credential/path leakage in traces and serialized errors.

Tests assert secret redaction in errors and span attributes and assert structured failure shapes for proof mismatch, HTTP 500, and timeouts.

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

Note

Structure relay environment connector errors with redacted URL diagnostics and typed reasons

  • Adds userId, deviceId, stage, and redacted httpBaseUrl diagnostics (input length, protocol, hostname) to EnvironmentMintRequestFailed, EnvironmentMintRequestTimedOut, and EnvironmentMintResponseInvalid error classes in EnvironmentConnector.ts.
  • Replaces raw endpoint URLs in span attributes and logs with structured diagnostic fields via new urlDiagnosticSpanAttributes and httpBaseUrlDiagnosticFields helpers.
  • Reworks verifyWithEnvironmentKeys, verifyEnvironmentResponse, and verifyEnvironmentHealthResponse to return discriminated results with structured reason codes and optional causes instead of booleans or Option values.
  • Adds static fromEndpoint constructors to all three error classes to enforce consistent redaction at construction sites.
  • Behavioral Change: error messages now include stage/reason context; span attributes record URL diagnostics rather than raw URLs; callers of the verification utilities receive structured reasons instead of booleans.

Macroscope summarized 86ee1b0.

@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: 4adec5e7-b736-499b-b03a-31f64c5b3316

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/relay-environment-mint-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:L 100-499 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 adds structured diagnostic fields to error classes and redacts sensitive URL components (credentials, paths, query params) from logs and telemetry. The underlying verification and connection logic remains unchanged - the refactoring improves error messages without altering behavior.

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

juliusmarminge and others added 3 commits June 20, 2026 09:31
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/relay-environment-mint-errors branch from 07aacdc to de7427d Compare June 20, 2026 16:58
@juliusmarminge
juliusmarminge changed the base branch from main to codex/redact-dpop-request-target June 20, 2026 16:58
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 16:58

Dismissing prior approval to re-evaluate de7427d

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 17:14

Dismissing prior approval to re-evaluate 86ee1b0

@juliusmarminge
juliusmarminge merged commit fddc7a2 into codex/redact-dpop-request-target Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/relay-environment-mint-errors branch June 20, 2026 18:38
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