Skip to content

[codex] Structure environment cloud HTTP errors#3392

Merged
juliusmarminge merged 4 commits into
codex/cloud-http-error-boundariesfrom
codex/structure-environment-http-errors
Jun 20, 2026
Merged

[codex] Structure environment cloud HTTP errors#3392
juliusmarminge merged 4 commits into
codex/cloud-http-error-boundariesfrom
codex/structure-environment-http-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • replace caller-supplied cloud HTTP messages with typed reasons and operations
  • derive the existing response messages from structural attributes
  • preserve exact internal causes for stack traces while excluding them from encoded HTTP bodies
  • expose relay request phase/status diagnostics through the boundary

Tests

  • vp test apps/server/src/cloud/http.test.ts
  • vp test apps/server/src/server.test.ts
  • vp test apps/mobile/src/features/cloud/linkEnvironment.test.ts
  • vp check
  • vp run typecheck
  • vp run lint:mobile

Stacked on #3246.


Note

Medium Risk
Touches shared cross-peer HTTP contracts and many T3 Connect cloud paths (link, health, mint, relay); behavior is mostly message shape and logging, with backward-compatible decoding, but mis-encoded errors could affect mobile/relay clients during rollout.

Overview
Environment cloud HTTP errors now use typed reason / operation fields instead of ad-hoc message strings at call sites. In environmentHttp.ts, 400/401/409 responses take enum reasons with derived user-facing messages; 500 responses add operation plus optional relayOperation, relayPhase, and responseStatus for relay failures.

apps/server/src/cloud/http.ts routes all connect handlers through failEnvironmentCloudInternalError, which builds these structured errors, logs operation (and relay context) with causeTag only, and still attaches full cause on the in-process error while encoding omits cause.

Rolling deploy compatibility: optional schema fields and constructors accept legacy message-only JSON on decode; new code must pass structured context.

Tests were updated for cloud_cli_authorization_required, encoded 500 bodies, legacy decode, and relay offline handling with operation.

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

Note

Add structured reason and operation codes to cloud environment HTTP errors

  • Introduces enums for bad request reasons, unauthorized reasons, conflict reasons, internal operation codes, and relay operation/phase in environmentHttp.ts, replacing free-form message strings with structured fields.
  • Updates all cloud HTTP error classes (EnvironmentHttpBadRequestError, EnvironmentHttpUnauthorizedError, EnvironmentHttpConflictError, EnvironmentHttpInternalServerError, etc.) to derive standardized messages from reason/operation codes while preserving legacy message-only decoding for rolling deployments.
  • Refactors all handlers and utilities in http.ts to construct errors with typed reason or operation fields instead of inline message strings.
  • Behavioral Change: Clients parsing error bodies will now see additional structured fields (reason, operation, relayOperation, relayPhase) alongside messages; legacy message-only payloads are still decoded correctly.

Macroscope summarized 7d11df3.

@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: b3bbb87c-2fad-4432-8f59-90d640e1c540

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/structure-environment-http-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 refactors HTTP error handling to use typed reason codes instead of free-form message strings, with messages derived from lookup tables. The actual error behavior and messages remain unchanged, with backward-compatible decoding for rolling deployments.

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

@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 15:02

Dismissing prior approval to re-evaluate 744a307

@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). size:L 100-499 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). size:XL 500-999 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/cloud-http-error-boundaries branch from 6c12fe1 to 1c4bd6e Compare June 20, 2026 16:56
@juliusmarminge juliusmarminge force-pushed the codex/structure-environment-http-errors branch from 352b1b4 to 1e09188 Compare June 20, 2026 17:04
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 17:04

Dismissing prior approval to re-evaluate 1e09188

@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/structure-environment-http-errors branch from 1e09188 to 73fb3f6 Compare June 20, 2026 17:12
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 17:12

Dismissing prior approval to re-evaluate 73fb3f6

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
juliusmarminge and others added 4 commits June 20, 2026 10:18
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>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/structure-environment-http-errors branch from 73fb3f6 to 7d11df3 Compare June 20, 2026 17:19
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 17:19

Dismissing prior approval to re-evaluate 7d11df3

@juliusmarminge juliusmarminge merged commit f785979 into codex/cloud-http-error-boundaries Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/structure-environment-http-errors branch June 20, 2026 18:35
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