Skip to content

[codex] Preserve auth HTTP failure diagnostics#3419

Closed
juliusmarminge wants to merge 2 commits into
codex/redact-dpop-request-targetfrom
codex/auth-http-diagnostics
Closed

[codex] Preserve auth HTTP failure diagnostics#3419
juliusmarminge wants to merge 2 commits into
codex/redact-dpop-request-targetfrom
codex/auth-http-diagnostics

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • retain exact underlying causes on typed auth HTTP 500 errors while keeping public JSON schemas redacted
  • log only bounded failure tags and reason counts, and suppress synthetic interruption failures
  • replace the remaining broad cookie catch with exhaustive catchTags handling

Validation

  • vp test apps/server/src/auth/http.test.ts apps/server/src/auth/EnvironmentAuth.test.ts
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Stacked on #3240.


Note

Medium Risk
Touches auth HTTP 500 and logging paths where mishandling could hide real failures or leak data; changes are guarded by new tests and redacted API encoding.

Overview
Auth HTTP internal failures now keep the full underlying cause on a typed EnvironmentHttpInternalError, while public JSON still encodes only code, reason, and traceId (no raw errors in responses).

Logging no longer dumps full Cause/error objects. Request and operation failures log a bounded failureTag plus reason/failure/defect/interruption counts. Request finalizers skip logging when the exit is interrupt-only.

failEnvironmentInternal re-propagates nested interruption causes instead of turning them into synthetic 500s. browserSession cookie handling uses catchTags for CookieError only, passing the cause into internal failure handling.

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

Note

Preserve auth HTTP failure diagnostics by summarizing causes instead of serializing them

  • Replaces raw cause/error serialization in auth HTTP logs with bounded diagnostics: a trimmed failureTag and counts of failures, defects, and interruptions via a new failureLogAttributes helper.
  • Adds findInterruptCause to detect nested interruption causes and re-propagate them directly, avoiding conversion into synthetic internal errors and suppressing redundant logs.
  • Introduces EnvironmentHttpInternalError with a bounded failureTag field and preserved original cause as a defect, replacing the generic internal error type.
  • Limits annotateEnvironmentRequest finalizer so it skips logging entirely when the exit cause contains only interrupts.
  • Narrows the browserSession cookie error catch to only handle CookieError, letting other errors fall through to upstream handling.

Macroscope summarized f0537a8.

@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: a45a65f5-35b3-4d38-a1ea-48d64d1ce31c

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/auth-http-diagnostics

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: Needs human review

Changes modify files in the auth directory (apps/server/src/auth/http.ts), which requires human review regardless of change complexity per security guidelines.

No code changes detected at f0537a8. Prior analysis still applies.

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

@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from 0f8b837 to edf63a7 Compare June 20, 2026 22:46
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from f476f6d to 519cb0a Compare June 20, 2026 22:47
@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from edf63a7 to d430f59 Compare June 20, 2026 22:50
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 519cb0a to 265d3cb Compare June 20, 2026 22:51
@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from d430f59 to fae19ef Compare June 20, 2026 23:11
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 265d3cb to 55daaa4 Compare June 20, 2026 23:11
@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from fae19ef to 2b5e1cf Compare June 20, 2026 23:20
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 55daaa4 to 6d9fb38 Compare June 20, 2026 23:20
@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from 2b5e1cf to 8728ebf Compare June 20, 2026 23:49
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 6d9fb38 to 5697b83 Compare June 20, 2026 23:49
@juliusmarminge juliusmarminge force-pushed the codex/server-auth-error-boundaries branch from 8728ebf to 55e9cd5 Compare June 21, 2026 00:08
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 5697b83 to a1f24c7 Compare June 21, 2026 00:08
Base automatically changed from codex/server-auth-error-boundaries to codex/redact-dpop-request-target June 21, 2026 00:14
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from a1f24c7 to c26e2ff Compare June 21, 2026 00:21
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from 70fdb85 to 5a80908 Compare June 21, 2026 00:21
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from c26e2ff to 89040c9 Compare June 21, 2026 00:28
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch 2 times, most recently from 553daf6 to ed36096 Compare June 21, 2026 00:38
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 89040c9 to 2d37a35 Compare June 21, 2026 00:38
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from ed36096 to 15aa01a Compare June 21, 2026 01:10
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 2d37a35 to 307df64 Compare June 21, 2026 01:10

@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.

Autofix Details

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

  • ✅ Fixed: Interrupt missed in Cause
    • Extracted the loop body into a recursive walkForInterrupt helper that, upon encountering a non-interrupt-only Cause, iterates its Fail reasons and continues walking each error's .cause chain to find nested interrupt causes.

Create PR

Or push these changes by commenting:

@cursor push 5780d93e6f
Preview (5780d93e6f)
diff --git a/apps/server/src/auth/http.ts b/apps/server/src/auth/http.ts
--- a/apps/server/src/auth/http.ts
+++ b/apps/server/src/auth/http.ts
@@ -83,10 +83,27 @@
 
 function findInterruptCause(input: unknown): Cause.Cause<never> | undefined {
   const seen = new Set<object>();
+  return walkForInterrupt(input, seen, 0);
+}
+
+function walkForInterrupt(
+  input: unknown,
+  seen: Set<object>,
+  depth: number,
+): Cause.Cause<never> | undefined {
   let current = input;
-  for (let depth = 0; depth < MAX_CAUSE_CHAIN_DEPTH; depth += 1) {
+  for (let d = depth; d < MAX_CAUSE_CHAIN_DEPTH; d += 1) {
     if (Cause.isCause(current)) {
-      return Cause.hasInterruptsOnly(current) ? (current as Cause.Cause<never>) : undefined;
+      if (Cause.hasInterruptsOnly(current)) {
+        return current as Cause.Cause<never>;
+      }
+      for (const reason of current.reasons) {
+        if (Cause.isFailReason(reason)) {
+          const found = walkForInterrupt(reason.error, seen, d + 1);
+          if (found !== undefined) return found;
+        }
+      }
+      return undefined;
     }
     if (typeof current !== "object" || current === null || seen.has(current)) {
       return undefined;

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

Comment thread apps/server/src/auth/http.ts
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 307df64 to 07d8a37 Compare June 21, 2026 01:26
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from 15aa01a to bd937be Compare June 21, 2026 01:26
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 07d8a37 to e9e9089 Compare June 21, 2026 01:38
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from bd937be to 517c1ea Compare June 21, 2026 01:38
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from 517c1ea to 8d916bc Compare June 21, 2026 01:44
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from e9e9089 to 629ce09 Compare June 21, 2026 01:44
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 21, 2026
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from 8d916bc to 7670d78 Compare June 21, 2026 01:51
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 629ce09 to 9c1fed6 Compare June 21, 2026 01:51
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Jun 21, 2026
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from 7670d78 to 1ed6271 Compare June 21, 2026 02:03
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 9c1fed6 to f5fe411 Compare June 21, 2026 02:04
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 21, 2026

@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: IPC openExternal breaks boolean contract
    • Added Effect.orElseSucceed(() => false) to the IPC handler so that ElectronShellOpenExternalError is caught and returns false instead of rejecting the IPC call, preserving the boolean contract for renderer callers.

Create PR

Or push these changes by commenting:

@cursor push f71e08ecb0
Preview (f71e08ecb0)
diff --git a/apps/desktop/src/ipc/methods/window.ts b/apps/desktop/src/ipc/methods/window.ts
--- a/apps/desktop/src/ipc/methods/window.ts
+++ b/apps/desktop/src/ipc/methods/window.ts
@@ -141,6 +141,6 @@
   result: Schema.Boolean,
   handler: Effect.fn("desktop.ipc.window.openExternal")(function* (url) {
     const shell = yield* ElectronShell.ElectronShell;
-    return yield* shell.openExternal(url);
+    return yield* shell.openExternal(url).pipe(Effect.orElseSucceed(() => false));
   }),
 });

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

Reviewed by Cursor Bugbot for commit f5fe411. Configure here.

Comment thread apps/desktop/src/electron/ElectronShell.ts
@juliusmarminge juliusmarminge force-pushed the codex/redact-dpop-request-target branch from c91fad6 to 9e0c536 Compare June 21, 2026 02:22
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from f5fe411 to efacbf7 Compare June 21, 2026 02:24
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Jun 21, 2026
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from efacbf7 to 15a2898 Compare June 21, 2026 02:44
juliusmarminge and others added 2 commits June 20, 2026 20:12
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/auth-http-diagnostics branch from 15a2898 to f0537a8 Compare June 21, 2026 03:12
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