Repository navigation
feat(server): gate external integration values by client API version - #53824
Closed
opencode-agent[bot] wants to merge 1 commit into
Closed
opencode-agent[bot] wants to merge 1 commit into
opencode-agent[bot] wants to merge 1 commit into
Conversation
Clients now send x-opencode-api-version. Clients that send no header (v2.0.24 and earlier) reject external integration methods, connections, and credentials, so integration.list, integration.get, and credential.list omit those values for them instead of failing the whole response.
Contributor
Author
|
Closing: client SDKs are expected to match the server version exactly, and the HTTP protocol only gets additive changes, so the server doesn't need to hold back new values from older clients. Reopen if that changes. |
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.
Issue for this PR
Follow-up to #53672. A newer server breaks older clients'
integration.listdecoding.Type of change
What does this PR do?
#53672 added the
externalintegration method, connection and credential type. Clients on v2.0.24 and earlier decodeIntegration.Method,Connection.CredentialInfo.methodandCredential.Valueas closed unions, so anyexternalvalue fails the whole response. Bedrock always advertises itsaws-profilemethod, sointegration.listfrom a current server fails to decode for every older SDK or remote/paired client, even when no one has connected an external credential.This adds client API-version gating:
@opencode/protocol/api-versiondefines thex-opencode-api-versionheader and the current version (2), with a log of what each version can decode.@opencode/clientkeeps its own copy because the promise client can't import protocol; a test checks that the two copies match.packages/server/src/api-version.tsreads the header. A missing or invalid header means version1, which covers every already-released client. For version 1,integration.list/integration.getleave outexternalmethods and connections, andcredential.listleaves outexternalcredentials. These are the only endpoints that return those schemas.API_VERSIONand add the omission for lower versions in the server'sapi-version.ts. Once the older versions are no longer supported, delete the omission.Version-1 clients just don't see external connections. That's correct for them, since they can't use them anyway.
This doesn't make clients tolerate unknown values; that belongs in codegen, and with it in place additive changes wouldn't need a version bump. It doesn't cover old binaries reading
externalrows from a shared database, or policy actions renamed in config responses.How did you verify your code works?
packages/server/test/api-version.test.ts: registers an integration with key and external methods, creates an external credential and a key credential, then calls/api/integration,/api/integration/:idand/api/credentialwith version 2, with no header, with1, and with a malformed header. The test fails without the handler changes.bun run typecheckpasses inserver,clientandprotocol. Server testsapi-version,provider,handler-policy,fetchandcorsall pass.v2(46c69bc35c), with or without this PR: the stale integration/session method list assertions, the session Effect decode test, and the effect/service import-boundary check.Checklist
Requested by: @neriousy (Filip via Slack)