Skip to content

fix(core): keep Console HTTP failure details and name the recovery command - #56791

Open
reynold-hu wants to merge 2 commits into
anomalyco:devfrom
reynold-hu:console-auth-diagnostics
Open

reynold-hu wants to merge 2 commits into
anomalyco:devfrom
reynold-hu:console-auth-diagnostics

Conversation

@reynold-hu

@reynold-hu reynold-hu commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #56782

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Console HTTP failures lost their cause twice: post only kept the status code, so a connect/oauth 400 or a device-code 429 surfaced as non 2xx status code (400 POST ...) in both the API error and the log, with no response body and no retry-after. The signed-out message also told users to reconnect without naming the command that does it.

  • post now reads the failed response body (trimmed to 300 characters) and retry-after, logs them with the URL and status, and fails with a message such as OpenCode Console request failed (HTTP 429: retry after 7: {"error":"slow_down",...}). The integration handler already forwards error.cause.message, so the CLI shows it.
  • The Console OAuth signed-out message now reads `Reconnect OpenCode Console to continue; run ``opencode auth login```. It is used for the connection status and by the inference 401/403 explainer.

Validating a credential at connect time is intentionally left out: it adds a request to the connect path and should be decided separately.

How did you verify your code works?

  • New test in packages/core/test/plugin/provider-opencode.test.ts: the device-code endpoint answers 429 with retry-after: 7 and a body; oauth.connect rejects with an Integration.AuthorizationError whose cause contains HTTP 429, retry after 7, and slow_down. On the parent commit the cause is only HttpClientError: StatusCode: non 2xx status code (429 ...).
  • Updated the two existing signed-out message assertions.
  • Full test/plugin/provider-opencode.test.ts: 41 pass, 0 fail. packages/core typecheck passes.

Screenshots / recordings

No UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #56499, #55675

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

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

Looks good. On the base, a device-code 429 surfaces only as non 2xx status code (429 POST …). With this change, the PR's test (run against the base and the PR) shows the status, retry-after and the response body in both the error and the log. The provider tests (41/41) and the packages/core typecheck pass. I couldn't drive opencode auth login end to end because the CLI's server process doesn't start from source in my environment (on base too).

requireOk only affects the status-checked post to device/code. Token polling (statusOk = false) and the invalid_grant refresh path are unchanged. No caller relies on the HttpClientError type, so swapping it for a plain Error is safe.

Public API: no SDK, HTTP route, config or CLI changes. Only the text of the Console needs_auth connection status and the signed-out error changes.

One non-blocking point about where the new signed-out wording is shown, inline.

Related: #56499, #55675

// Console's 401 when the session behind the access token was revoked or expired.
const Unauthorized = Schema.Struct({ _tag: Schema.Literal("Unauthorized") })
const signedOutMessage = "Reconnect OpenCode Console to continue"
const signedOutMessage = "Reconnect OpenCode Console to continue; run `opencode auth login`"

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.

This string is also the needs_auth message for the connection status shown in the TUI and desktop app, where people usually recover through /connect → OpenCode Console (that's what #55675's reporter was pointed to). A CLI command there may confuse them. Also, plain opencode auth login prompts for an integration; opencode auth login opencode would go straight to Console. Could the wording cover both, or name the integration?

@reynold-hu

Copy link
Copy Markdown
Contributor Author

Addressed the inline wording point in c49a446: the message now names both recovery paths, use /connect or run opencode auth login opencode, so the TUI/desktop flow and the CLI command are both discoverable. Tests updated; provider-opencode 41/41, typecheck clean.

This branch has not been deployed

No deployments
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.

auth: expired Console credential gives a non-actionable error, and 400/429 during re-auth are never logged

1 participant