Skip to content

fix: opencode reads the opencode 2 credential database (0.0.92) - #124

Merged
okisdev merged 2 commits into
mainfrom
opencode-v2-credential
Nov 22, 2026
Merged

okisdev merged 2 commits into
mainfrom
opencode-v2-credential

Conversation

@okisdev

@okisdev okisdev commented Nov 22, 2026

Copy link
Copy Markdown
Owner

summary

  • opencode 2.3 keeps opencode auth login credentials in the credential table of ~/.local/share/opencode/opencode.db, not in auth.json, so 0.0.91 read a stale June key from the old file and every Go request returned HTTP 401 on a freshly logged in machine
  • the companion now takes the most recently updated active opencode-go row whose value is { "type": "key", "key": ... }, then falls back to the opencode 1 auth.json; OPENCODE_GO_API_KEY still wins over both
  • the database is opened read only with node:sqlite in a child Node process started with --disable-warning=ExperimentalWarning (Node 22 prints an experimental warning otherwise); the key returns over stdout, never args, and neither store is ever written

test plan

already verified

  • node --test tests/opencode-*.test.mjs: 37/37 on Node 26, and the provider and companion suites pass on Node 22.23.2; new cases cover active row over inactive and over the legacy file, non key and other integration rows ignored, a malformed database, and an end to end task whose database key reaches the codex child and the Go API stub but no arg or job record
  • npm test: 3183 tests, 3180 pass, 3 skipped, 0 fail; sync check and plugin validation pass
  • live on a machine logged in with opencode 2.3.2 and no env var: /opencode:setup reports ready, where 0.0.91 returned HTTP 401

reviewer should verify

  • with opencode 2.x logged in to OpenCode Go and OPENCODE_GO_API_KEY unset, /opencode:setup reports ready

opencode 2.3 keeps logins in the credential table of opencode.db, not auth.json, so the companion read a stale key and got HTTP 401. it now takes the active opencode-go key row read only in a child process, then falls back to auth.json.
@okisdev
okisdev merged commit cab08ba into main Nov 22, 2026
4 checks passed
@okisdev
okisdev deleted the opencode-v2-credential branch November 22, 2026 11:34
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.

1 participant