Skip to content

fix: backfill legacy Bedrock AI provider rows and stale model config strings (#26155)#26453

Merged
f0ssel merged 1 commit into
release/2.34from
cj/r234/codagt-548
Jun 17, 2026
Merged

fix: backfill legacy Bedrock AI provider rows and stale model config strings (#26155)#26453
f0ssel merged 1 commit into
release/2.34from
cj/r234/codagt-548

Conversation

@johnstcn

Copy link
Copy Markdown
Member

Fixes CODAGT-548

Adds two idempotent startup backfills run after `newAPI():

  • BackfillBedrockProviderType: promotes ai_providers rows from type=anthropic with Bedrock settings to type=bedrock.
  • BackfillChatModelConfigProviderStrings: fixes stale chat_model_configs.provider = "anthropic" strings on rows whose linked provider was just promoted.
  • UpdateAIProvider query now also writes the type column, so the fix persists on any subsequent PATCH.

🤖 Generated by Claude with oversight from a human.

(cherry picked from commit a4c867f)

…strings (#26155)

Fixes CODAGT-548

Adds two idempotent startup backfills run after `newAPI():

- `BackfillBedrockProviderType`: promotes `ai_providers` rows from
`type=anthropic` with Bedrock settings to `type=bedrock`.
- `BackfillChatModelConfigProviderStrings`: fixes stale
`chat_model_configs.provider = "anthropic"` strings on rows whose linked
provider was just promoted.
- `UpdateAIProvider` query now also writes the `type` column, so the
fix persists on any subsequent PATCH.

> 🤖 Generated by Claude with oversight from a human.

(cherry picked from commit a4c867f)
@johnstcn johnstcn self-assigned this Jun 17, 2026
Copilot AI review requested due to automatic review settings June 17, 2026 10:26
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

CODAGT-548

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds startup backfills to correct legacy AWS Bedrock provider rows that were stored as type=anthropic, and to repair stale chat_model_configs.provider strings that no longer match the provider’s promoted type. It also updates the UpdateAIProvider SQL query to persist provider type changes going forward.

Changes:

  • Add startup backfills: promote legacy Bedrock providers to type=bedrock, then update stale chat_model_configs.provider strings to bedrock.
  • Update UpdateAIProvider to write the type column, and update call sites to pass Type.
  • Add DB, auth, metrics, and mock plumbing plus regression tests (including encrypted-settings coverage in Enterprise).

Reviewed changes

Copilot reviewed 15 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
enterprise/dbcrypt/dbcrypt_internal_test.go Updates dbcrypt tests to populate UpdateAIProviderParams.Type.
enterprise/coderd/x/chatd/chatd_test.go Updates enterprise chatd tests to pass provider Type into UpdateAIProvider.
enterprise/coderd/ai_providers_backfill_test.go Adds enterprise regression test verifying backfill works with encrypted settings.
coderd/x/chatd/chatd_test.go Updates OSS chatd tests to pass provider Type into UpdateAIProvider.
coderd/database/queries/chatmodelconfigs.sql Adds BackfillChatModelConfigProvider SQL update to fix stale provider strings.
coderd/database/queries/ai_providers.sql Updates UpdateAIProvider SQL to also write type.
coderd/database/queries.sql.go Regenerates sqlc output for the updated UpdateAIProvider and new backfill query.
coderd/database/querier.go Extends sqlc querier interface with BackfillChatModelConfigProvider (returns sql.Result).
coderd/database/dbmock/dbmock.go Regenerates mocks to include BackfillChatModelConfigProvider.
coderd/database/dbmetrics/querymetrics.go Adds metrics instrumentation for BackfillChatModelConfigProvider.
coderd/database/dbauthz/dbauthz.go Adds RBAC enforcement wrapper for BackfillChatModelConfigProvider.
coderd/database/dbauthz/dbauthz_test.go Adds RBAC test coverage for the new DB method.
coderd/ai_providers.go Ensures PATCH update path passes existing Type to UpdateAIProvider.
coderd/ai_providers_migrate.go Adjusts env seeding drift detection and legacy Bedrock env behavior to align with type=bedrock.
coderd/ai_providers_migrate_test.go Updates/extends seed tests for the new Bedrock type behavior and idempotency after backfill.
coderd/ai_providers_backfill.go Adds the two startup backfill functions.
coderd/ai_providers_backfill_test.go Adds DB-backed and mocked tests for both backfills and failure paths.
cli/server.go Wires backfills into server startup after newAPI() and env seeding.
Files not reviewed (3)
  • coderd/database/dbmetrics/querymetrics.go: Generated file
  • coderd/database/dbmock/dbmock.go: Generated file
  • coderd/database/querier.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +30
key := make([]byte, 32)
_, _ = rand.Read(key)
ciphers, err := dbcrypt.NewCiphers(key)
Comment thread cli/server.go
Comment on lines +1032 to +1034
// Must run after BackfillBedrockProviderType; shares aibridgeInitCtx so
// a timeout on the first backfill will skip this one until next startup.
coderd.BackfillChatModelConfigProviderStrings(aibridgeInitCtx, options.Database, logger.Named("aibridge.backfill"))
@f0ssel f0ssel merged commit da215b3 into release/2.34 Jun 17, 2026
53 checks passed
@f0ssel f0ssel deleted the cj/r234/codagt-548 branch June 17, 2026 15:56
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants