{{ message }}
Repository navigation
refactor(schema): store key credential form answers in metadata - #56934
Merged
Merged
Conversation
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
Setup-form answers were stored in two different places depending on how a credential was created:
configurationmetadatametadata(written by each plugin)Readers had to check both. Azure read
configuration.resourceName ?? metadata.resourceName, and Snowflake did the same foraccount. Keys imported from V1 already kept their answers inmetadata.Change
configurationis removed from the public credential contract. Key credentials store their form answers inmetadata, as external and OAuth credentials already do.integration.ts: the key connect flow writes the answer tometadata.model-resolver.ts: merges onlymetadatainto provider settings, as it already did for every other credential type.metadataonly.configuration.Existing data
There is no database migration. Only two readers still accept the old shape, through
@opencode/schema/credential-legacy, a storage and import schema that is not part of the public contract:CredentialLegacymerges a legacyconfigurationintometadata. When both share a key, the form answer wins, matching their old precedence in provider settings. Everything else usesCredential.Value, which treatsconfigurationas an unknown key.Compatibility
auth exportfiles from earlier releases keep their answers onauth import.POST /api/credentialcalls that still sendconfiguration: the field is ignored. Those calls should send form answers asmetadata.Credential.Keyno longer hasconfiguration. Read and write form answers inmetadata.metadatakeep working there. Those releases mergemetadatainto provider settings for every credential type, and Azure and Snowflake fall back tometadata.metadatainto the request body (azure: migrated resourceName is rejected as unknown_parameter #53443, fixed in fix(core): stop sending API key metadata as request body #53546). A key credential created by this release can therefore send its form answers as request parameters there. Azure in those releases also reads an API-key credential's resource only fromconfiguration, so Azure API-key credentials created by this release lose their resource name there. Credentials saved before upgrading are unaffected.Verification
packages/schema/test/credential-legacy.test.tschecks that:configurationmerges intometadatawith answers taking precedence;configurationis rejected;Credential.Valueignoresconfiguration.packages/core/test/credential.test.ts"reads key form answers stored in configuration before v2.1 as metadata": inserts a legacy row with raw SQL. It fails when the store decodes withCredential.Value.packages/cli/test/auth.test.ts"imports credentials exported before v2.1 with their form answers as metadata": fails whenauth importdecodes withCredential.Entry.Tests:
bun test test/credential.test.ts test/integration.test.ts test/model-resolver.test.ts test/pluginbun testbun testbun test test/auth.test.ts test/import-export.test.tsbun testTypecheck:
bun typecheckpasses in schema, protocol, core, client, cli, server, sdk, tui, plugin, and app, apart from errors already onv2.1.Generated files:
check:generatedpasses in packages/protocol, packages/client, and services/www.