fix: map empty bedrock settings strings to null#384
Merged
Conversation
A legacy agents-bedrock row with an empty stored settings blob imports with settings = null. Adopting it via an import block while the config sets only settings.bedrock.region plans model/small_fast_model/role_arn as known null, but stateFromProvider wrote types.StringValue("") for the server's echoed empty strings during the in-place update. null != "" violates Terraform's requirement that final state equal every known planned value, and because settings.bedrock has sensitive write-only leaves core masked it as ".settings: inconsistent values for sensitive attribute".
Map the server's empty strings back to null via stringValueOrNull (as role_arn already did), and reject an explicitly-configured "" at validate time with LengthAtLeast(1) since Coder drops empty strings on the wire (omitempty).
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
johnstcn
approved these changes
Jul 8, 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
Dogfood CI failed applying
module.ai.coderd_ai_provider.agents_bedrock:The failing row is a legacy
agents-bedrockprovider whose storedsettingsblob is empty — a shape current Coder can no longer produce (you can't get a provider into this state anymore), which is why prior testing never hit it. Dogfood adopts this pre-existing row via animportblock while the config declares onlysettings.bedrock.region = "us-east-2".Walking the flow:
settings = null. The empty stored blob makes the server returnsettings: null, soprovider.Settings.Bedrock == nilandstateFromProvider'sif provider.Settings.Bedrock != nilbranch is skipped entirely — the block is stored as null, and no""is ever written.model/small_fast_modelbecame known null. They areOptional+Computed, so they are first marked unknown, thenUseStateForUnknowncopies the imported prior-state known-null back (it only short-circuits when the entire prior state is null, i.e. a fresh create — not after an import)."". Because the config now setsregion, the PATCH sends a real bedrock object withmodelserialized as"". The server echoesBedrock != nilwithmodel: "", sostateFromProviderenters the branch and (pre-fix) wrotetypes.StringValue("").model= known null; appliedmodel="". Terraform requires final state to equal every known planned value, andnull != "". Sincesettings.bedrockcontains sensitive write-only leaves, core masks the offending leaf as the opaque.settings: inconsistent values for sensitive attribute.Fix
Map the server's empty bedrock strings (
region,model,small_fast_model,role_arn) back to null viastringValueOrNullinstateFromProvider, so absence has a single representation (role_arnalready did this). This makes the Update-path echo of""match the known-null plan.Coder drops empty optional strings on the wire (
omitempty), so a configured""reads back as null and would reproduce the same inconsistency. Reject that up front withstringvalidator.LengthAtLeast(1)on the four optional bedrock strings, turning an opaque apply-time failure into a clear validation error — omit the attribute instead of setting it empty.Notes
Added a pure-function regression test (
TestAIProviderStateFromProviderMapsEmptyBedrockStringsToNull) that fails pre-fix and passes post-fix without any mock server or Terraform, plus two schema-validation cases for the empty-string rejection. Documented the null-vs-""state-mapping footgun in AGENTS.md.