fix(console): route new Console keys to inference - #49036
Merged
Merged
Conversation
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
vaprdev
force-pushed
the
go-key-routing
branch
from
September 14, 2026 21:12
aea0888 to
bcd6ecc
Compare
hugojosefson
pushed a commit
to hugojosefson/opencode
that referenced
this pull request
Sep 18, 2026
rossigee
pushed a commit
to rossigee/opencode
that referenced
this pull request
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The V2 Console issues service-account API keys with the
oc_sk_prefix. The documented Go flow (create key in Console →/connect→ OpenCode Go → paste) sends them tohttps://opencode.ai/zen/go/v1, whereproxyInferencedecides whether to forward to the new inference application by looking the key up in the legacykeytable and checkingworkspace.migrated_at.New keys have never existed in that table, so the lookup returns nothing, the request falls through to the legacy Zen handler, and the user gets
Invalid API key.in the TUI.Change
inference-proxy.ts: keys starting withoc_sk_skip the legacy lookup and are forwarded to the mapped/inference/...path unconditionally. The destination owns authentication, revocation, and accounting as before.Old
sk-keys are unchanged: migrated workspaces forward, unmigrated workspaces stay on legacy Zen.Supporting cleanup in the same file:
migratedWorkspacehelper that filtersmigrated_at IS NOT NULLin SQL, so the caller only asks "is there a routable workspace?" (if (legacy && !workspace) return undefined).!go &&condition on theProviderTablejoin. Every/zen/go/*route usesmodelList: "lite", sohandler.tsalready passesprovider: undefinedfor Go; the proxy was re-checking what the caller owns.Why the prefix is a safe discriminator
console/core/src/key.ts,console/core/script/create-api-key.ts) producesk-+ 64 alphanumerics and always have.opencode.key: 3,729,853 rows, all matching^sk-[A-Za-z0-9]{64}$.service_api_keyprefixes are onlyoc_sk_...(native) andsk-...(imported legacy).No format validation beyond the prefix: a forged
oc_sk_gains nothing but a 401 from the destination.Verification
bun typecheckinpackages/console/app; pre-commit turbo typecheck across the repo.fetch, so a unit test would need to mock both. Not added.ConsoleMigration.inferenceUrl, so forwarded requests there return 503;oc_sk_keys on preview move from legacy's 401 to that 503, same as migrated keys already do.Companion
anomalyco/opencode-console#2280 updates the inference README "Public Routing Gate" section to reference this change.