Skip to content

fix(oauth-connect): guard against poll daemon errors and malformed start response#29593

Merged
credence-the-bot[bot] merged 1 commit into
credence-the-bot/oauth-connect-daemon-flowfrom
run-plan/oauth-connect-flow/fix-r2-1
May 5, 2026
Merged

fix(oauth-connect): guard against poll daemon errors and malformed start response#29593
credence-the-bot[bot] merged 1 commit into
credence-the-bot/oauth-connect-daemon-flowfrom
run-plan/oauth-connect-flow/fix-r2-1

Conversation

@credence-the-bot
Copy link
Copy Markdown
Contributor

@credence-the-bot credence-the-bot Bot commented May 5, 2026

Summary

  • Fix: poll loop now breaks early on daemon errors (statusCode present) instead of waiting full 5-min timeout
  • Fix: ok:true + missing auth_url now surfaces error instead of silently falling back to in-process (which has heap-split bug for gateway transport)
  • Tests: two new test cases covering both new guards

Fixes gaps found during plan self-review round 2 for oauth-connect-daemon-flow.md


Open in Devin Review

@credence-the-bot credence-the-bot Bot merged commit 653f474 into credence-the-bot/oauth-connect-daemon-flow May 5, 2026
@credence-the-bot credence-the-bot Bot deleted the run-plan/oauth-connect-flow/fix-r2-1 branch May 5, 2026 04:42
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

View 3 additional findings in Devin Review.

Open in Devin Review

}
}
if (!r.ok && r.statusCode !== undefined) {
return { status: "error", service: "?", error: r.error ?? "Daemon error during OAuth status poll" };
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.

🔴 User-facing error message uses "Daemon" instead of "assistant"

The fallback error string "Daemon error during OAuth status poll" at line 99 is user-facing — it flows through pollOAuthConnectStatusfinal.errorwriteError(final.error ?? ...) at assistant/src/cli/commands/oauth/connect.ts:472. AGENTS.md explicitly mandates: "In all user-facing text — CLI output, error messages, help strings… use 'assistant' instead of 'daemon'."

Suggested change
return { status: "error", service: "?", error: r.error ?? "Daemon error during OAuth status poll" };
return { status: "error", service: "?", error: r.error ?? "Assistant error during OAuth status poll" };
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

// than falling back to in-process (which would re-introduce the heap-split bug for
// gateway transport).
if (startResult.ok && !startResult.result?.auth_url) {
writeError("Daemon returned unexpected response for OAuth connect start");
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.

🔴 User-facing error message uses "Daemon" instead of "assistant"

The error string "Daemon returned unexpected response for OAuth connect start" is passed directly to writeError(), making it user-facing CLI output. AGENTS.md mandates: "In all user-facing text — CLI output, error messages… use 'assistant' instead of 'daemon'." The corresponding test assertion at assistant/src/cli/commands/oauth/__tests__/connect.test.ts:1016 would also need updating.

Suggested change
writeError("Daemon returned unexpected response for OAuth connect start");
writeError("Assistant returned unexpected response for OAuth connect start");
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

noanflaherty pushed a commit that referenced this pull request May 5, 2026
…ay` through daemon IPC (#29596)

* fix(oauth): route `assistant oauth connect --callback-transport=gateway` through daemon IPC (#29570)

* fix(oauth): route assistant oauth connect --callback-transport=gateway through daemon IPC

* fix(oauth-connect): pass lint, type-check, and openapi-check

- Sort imports per simple-import-sort/imports rule (autofix)
- Add eslint-disable for the intentionally-let resolvedState binding
- Narrow OAuthConnectResult union before reading .error (split into two if branches)
- Narrow OAuthConnectStatusResponse before reading .error in CLI poll loop
- Regenerate openapi.yaml to include the 2 new internal routes

* fix: use operationId and structured params for cliIpcCall (Devin/Codex P1 review)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: thread grantedScopes through IPC path to avoid empty-scopes inconsistency (Devin review)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(oauth): align IPC poll timeout with 5-min loopback OAuth window (Codex review)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: credence-the-bot <credence@vellum.ai>
Co-authored-by: credence-the-bot[bot] <183148327+credence-the-bot[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: surface daemon errors instead of silent fallback; add gateway transport test and policy tests (#29590)

Co-authored-by: credence-the-bot <credence@vellum.ai>

* fix: add defensive guards for poll daemon errors and ok:true missing auth_url (#29593)

Co-authored-by: credence-the-bot <credence@vellum.ai>

* test: add missing test coverage for oauth-connect daemon flow (round-3) (#29595)

Co-authored-by: credence-the-bot <credence@vellum.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: suppress browser-wait log in JSON mode; sweep expired OAuth state on insertion (#29597)

* fix: suppress browser-wait log in JSON mode; sweep expired state on insert

* test: make JSON-mode log suppression test exercise the actual if (!jsonMode) guard

Configure the logger mock to write to process.stdout in the specific test so
the test would fail if the guard were removed from connect.ts. Also reset
mockLogInfo to no-op in beforeEach for test isolation.

---------

Co-authored-by: credence-the-bot <credence@vellum.ai>

* fix(oauth): replace 'Daemon' with 'assistant' in user-facing error strings (#29603)

* fix(oauth): replace 'Daemon' with 'assistant' in user-facing error strings

* test: update assertion to match new 'assistant' string from devin nit fix

The previous commit replaced 'Daemon' with 'assistant' in user-facing
error strings (per Devin review), but missed updating the test that
asserts on the old 'Daemon returned unexpected response' wording.

---------

Co-authored-by: credence-the-bot <credence@vellum.ai>
Co-authored-by: credence-the-bot[bot] <credence-the-bot[bot]@users.noreply.github.com>

* fix(security): add IPC policy entries for daemon OAuth connect routes (#29612)

Closes Codex P1 on #29596 by adding IPC policy entries for the new daemon OAuth connect routes (`internal_oauth_connect_start`, `internal_oauth_connect_status`). Mirrors the pattern from #29571 for the MCP OAuth routes. 4-line additive change, 6/6 tests pass. Both Codex and Devin re-reviewed clean.

---------

Co-authored-by: credence-the-bot[bot] <277301654+credence-the-bot[bot]@users.noreply.github.com>
Co-authored-by: credence-the-bot <credence@vellum.ai>
Co-authored-by: credence-the-bot[bot] <183148327+credence-the-bot[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: credence-the-bot[bot] <credence-the-bot[bot]@users.noreply.github.com>
Co-authored-by: credence-the-bot[bot] <credence-the-bot@vellum.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants