Skip to content

fix(core): resolve device verification URL - #44021

Merged
kitlangton merged 2 commits into
v2from
device-url
Aug 21, 2026
Merged

fix(core): resolve device verification URL#44021
kitlangton merged 2 commits into
v2from
device-url

Conversation

@kitlangton

@kitlangtonkitlangton commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What

Fix OpenCode Console device authorization links when the Console API returns an origin-rooted verification path.

Before / After

Before: The Console API returns /console/device?.... Since the default server is https://opencode.ai/console, the client stripped the leading slash and appended the response to that full base, producing https://opencode.ai/console/console/device?.... The Console did not recognize that route and redirected a signed-in user to their organization page instead of device approval.

After: Verification URLs use standard URL resolution. Origin-rooted paths resolve against the server origin, relative paths resolve beneath the configured server base, and absolute HTTP(S) URLs remain unchanged. Malformed or non-HTTP(S) verification URLs fail as typed authorization errors instead of defects.

How

  • packages/core/src/plugin/provider/opencode.ts resolves verification_uri_complete with new URL(value, base) inside Effect.try and retains the HTTP(S) protocol check.
  • packages/core/test/plugin/provider-opencode.test.ts reproduces the production response shape, asserts that /console appears exactly once, and covers malformed verification responses.
  • Adds a patch changeset for @opencode-ai/core.

Scope

This does not change the Console API response or router. It only corrects client-side handling of the existing response contract.

Testing

  • bun run test test/plugin/provider-opencode.test.ts from packages/core: 13 passed
  • bun typecheck from packages/core
  • Push hook: repository-wide Turbo typecheck, 33 tasks passed
  • Production contract checked with POST https://opencode.ai/console/auth/device/code, which returned an origin-rooted /console/device?... verification URL

Flow

sequenceDiagram
participant CLI
participant Core
participant ConsoleAPI as Console API
participant Browser
CLI->>Core: Start device authorization
Core->>ConsoleAPI: POST /console/auth/device/code
ConsoleAPI-->>Core: verification_uri_complete=/console/device?...
Core-->>CLI: https://opencode.ai/console/device?...
CLI->>Browser: Open device approval route
Loading

Root Cause

Commit 40cd6989d2 changed the default server from https://console.opencode.ai to https://opencode.ai/console without updating the fallback path join or covering the production response shape in a test.

@kitlangton
kitlangton enabled auto-merge (squash) August 21, 2026 23:21
@kitlangton
kitlangton merged commit 3694149 into v2Aug 21, 2026
10 checks passed
@kitlangton
kitlangton deleted the device-url branch August 21, 2026 23:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@kitlangton