Skip to content

[codex] Structure cloud HTTP boundary errors#3246

Merged
juliusmarminge merged 4 commits into
codex/server-secret-store-errorsfrom
codex/cloud-http-error-boundaries
Jun 20, 2026
Merged

[codex] Structure cloud HTTP boundary errors#3246
juliusmarminge merged 4 commits into
codex/server-secret-store-errorsfrom
codex/cloud-http-error-boundaries

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Stacked on #3243.

Summary

  • represent relay configuration and request failures as structured Schema errors with operation, phase, method, URL, response status, and full cause context
  • classify HTTP client failures on the error class and keep public messages independent from cause text
  • replace broad predicate and single-tag catches in the cloud handlers with exact catchTags mappings
  • retain boundary redaction while logging the complete structured cause chain
  • remove the valueless CLI error forwarding alias and use namespace imports for Effect HTTP modules

Validation

  • vp test apps/server/src/cloud (30 tests)
  • vp check (passes; repository baseline warnings only)
  • vp run typecheck

Note

Medium Risk
Touches authentication, cloud linking, health/mint, and relay credential flows across contracts and the environment server; behavior changes are mostly error shape and redaction, but mis-mapped catch tags could surface wrong client messages.

Overview
Cloud HTTP errors move from ad-hoc message strings to reason/operation-coded contract types (EnvironmentHttpBadRequestReason, EnvironmentHttpUnauthorizedReason, EnvironmentHttpInternalOperation, relay operation/phase, conflict reasons). Constructors derive stable user-facing text; wire payloads keep optional fields so message-only legacy bodies still decode during rolling deploys.

Relay outbound calls gain CloudRelayRequestError (phase classification, URL diagnostics without secrets) and CloudRelayConfigurationError for bad T3CODE_RELAY_URL. relayClientRequest maps every HTTP client failure through fromClientFailure instead of stringifying causes into 500s.

failEnvironmentCloudInternalError now takes structured operation context, logs causeTag only (not full cause), and returns EnvironmentHttpInternalServerError with internal cause retained but omitted from encoded JSON (tests assert this).

Cloud handlers switch from broad catchIf / generic secret-store catches to Effect.catchTags with per-failure operation labels. Unauthorized CLI linking uses reason: cloud_cli_authorization_required. Validation and conflict paths use machine reasons instead of inline messages.

Tests cover redaction, legacy decode, reconcile link auth, and mobile link-proof error propagation.

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

Note

Structure cloud HTTP boundary errors with typed reason codes and operation diagnostics

  • Adds reason fields to 400, 401, and 409 error payloads (e.g. cloud_cli_authorization_required, invalid_relay_url) and structured operation/relayOperation/relayPhase fields to 500 payloads in environmentHttp.ts.
  • Introduces CloudRelayRequestError in http.ts to wrap relay client failures with phase diagnostics (encode-request, send-request, check-response-status, decode-response) and sanitized messages that don't leak sensitive URL parts or upstream details.
  • Refactors failEnvironmentCloudInternalError to log a causeTag instead of the raw cause, and replaces broad catchIf catches with Effect.catchTags throughout all cloud HTTP handlers.
  • Decoding of all error types remains backward-compatible with legacy message-only payloads.
  • Behavioral Change: consumeCloudReplayGuards now only swallows SecretStorePersistError with already-exists semantics; other secret store errors now propagate as failures instead of being silently ignored.

Macroscope summarized f785979.

@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: efa42eef-e932-4888-ad86-e4b2d8cd11ff

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/cloud-http-error-boundaries

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

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Refactors HTTP error handling from string messages to structured reason codes with backwards compatibility. Changes are mechanical, add secret-leakage prevention, and include comprehensive tests for the new error structure.

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

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/server-secret-store-errors branch from 47c0424 to 8090110 Compare June 20, 2026 16:56
@juliusmarminge juliusmarminge force-pushed the codex/cloud-http-error-boundaries branch from 6c12fe1 to 1c4bd6e Compare June 20, 2026 16:56
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 17:09

Dismissing prior approval to re-evaluate fe10a0b

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Structured cause dropped from logs
    • Added { cause } back to the Effect.logError call in failEnvironmentCloudInternalError so the structured cause chain is preserved in server logs, matching the pattern used by failEnvironmentInternal in auth/http.ts.

Create PR

Or push these changes by commenting:

@cursor push a6684f6aaa
Preview (a6684f6aaa)
diff --git a/apps/server/src/cloud/http.ts b/apps/server/src/cloud/http.ts
--- a/apps/server/src/cloud/http.ts
+++ b/apps/server/src/cloud/http.ts
@@ -201,7 +201,7 @@
 const failEnvironmentCloudInternalError =
   (message: string) =>
   (cause: unknown): Effect.Effect<never, EnvironmentHttpInternalServerError> =>
-    Effect.logError(message).pipe(
+    Effect.logError(message, { cause }).pipe(
       Effect.flatMap(() => Effect.fail(new EnvironmentHttpInternalServerError({ message, cause }))),
     );

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit fe10a0b. Configure here.

Comment thread apps/server/src/cloud/http.ts Outdated
Co-authored-by: codex <codex@users.noreply.github.com>
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 18:35

Dismissing prior approval to re-evaluate f785979

@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
@juliusmarminge juliusmarminge merged commit 050fbe6 into codex/server-secret-store-errors Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/cloud-http-error-boundaries branch June 20, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 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