Repository navigation
fix(core): keep Console HTTP failure details and name the recovery command - #56791
reynold-hu wants to merge 2 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
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.
| // 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`" |
There was a problem hiding this comment.
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?
|
Addressed the inline wording point in c49a446: the message now names both recovery paths, |
c49a446 to
c69baa0
Compare
Issue for this PR
Closes #56782
Type of change
What does this PR do?
Console HTTP failures lost their cause twice:
postonly kept the status code, so aconnect/oauth400 or a device-code 429 surfaced asnon 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.postnow reads the failed response body (trimmed to 300 characters) andretry-after, logs them with the URL and status, and fails with a message such asOpenCode Console request failed (HTTP 429: retry after 7: {"error":"slow_down",...}). The integration handler already forwardserror.cause.message, so the CLI shows it.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?
packages/core/test/plugin/provider-opencode.test.ts: the device-code endpoint answers 429 withretry-after: 7and a body;oauth.connectrejects with anIntegration.AuthorizationErrorwhose cause containsHTTP 429,retry after 7, andslow_down. On the parent commit the cause is onlyHttpClientError: StatusCode: non 2xx status code (429 ...).test/plugin/provider-opencode.test.ts: 41 pass, 0 fail.packages/coretypecheck passes.Screenshots / recordings
No UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #56499, #55675