{"record":{"id":"59726916ab34620b","repo":"hashicorp/terraform","slug":"failed-to-set-state-store-provider-configuration-597269","errorCode":null,"errorMessage":"Failed to set state store provider configuration: %w","messagePattern":"Failed to set state store provider configuration: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/state_migrate.go","lineNumber":312,"sourceCode":"\t\tbsf.StateStore = &workdir.StateStoreConfigState{\n\t\t\tType: rootMod.StateStore.Type,\n\t\t\tHash: uint64(cHash),\n\t\t\tProvider: &workdir.ProviderConfigState{\n\t\t\t\tSource:  &rootMod.StateStore.ProviderAddr,\n\t\t\t\tVersion: version,\n\t\t\t},\n\t\t\tProviderSupplyMode: rootMod.StateStore.ProviderSupplyMode,\n\t\t}\n\t\terr = bsf.StateStore.SetConfig(stateStoreConfigVal, dstB.ConfigSchema())\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store configuration: %w\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\t\terr = bsf.StateStore.Provider.SetConfig(providerConfigVal, dstB.ProviderSchema())\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store provider configuration: %w\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\t} else {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Unknown migration destination\",\n\t\t\t\"No configuration was provided for where to migrate the state to. Please ensure that a file with a .tf extension is present and contains valid state_store or backend configuration inside the terraform block.\",\n\t\t))\n\t}\n\n\t// present all errors from above together so user can fix them all at once\n\tif diags.HasErrors() {\n\t\tview.Diagnostics(diags)\n\t\treturn 1\n\t}\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/state_migrate.go#L294-L330","documentation":"Thrown during `terraform state migrate` to a state_store destination when bsf.StateStore.Provider.SetConfig(providerConfigVal, dstB.ProviderSchema()) fails. This captures the destination state-store *provider's* own configuration (distinct from the state store config) into the backend state file. The %w is the ctyjson marshal error against the provider's schema, naming the non-conforming attribute/type.","triggerScenarios":"Running `terraform state migrate` to a state_store where the provider configuration value produced by stateStoreInitFromConfig does not conform to the provider schema returned by dstB.ProviderSchema().","commonSituations":"Provider-level configuration attributes changed between provider versions; a provider alias block with invalid attributes; schema drift after upgrading the state-store provider; mixed required_providers entries referencing the same provider with differing versions.","solutions":["Read the wrapped %w to find the exact provider attribute/type that failed.","Align the provider configuration block with the state-store provider's documented schema.","Upgrade or pin the state-store provider consistently in required_providers and re-run migrate.","Remove stale provider alias blocks no longer matching the provider schema."],"exampleFix":"# before\nprovider \"foo\" {\n  alias    = \"state\"\n  legacy_field = true  # removed in current provider version\n}\n\n# after\nprovider \"foo\" {\n  alias  = \"state\"\n  region = \"us-east-1\"\n}","handlingStrategy":"validation","validationCode":"// verify the state-store *provider* config conforms to the provider schema\nfunc validateProviderConfig(val cty.Value, schema *configschema.Block) error {\n    _, err := ctyjson.Marshal(val, schema.ImpliedType())\n    return err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep provider configuration blocks aligned with the provider version in required_providers.","Remove stale provider alias blocks after provider upgrades.","Validate after every provider version change.","Pin provider versions to avoid silent schema drift."],"tags":["state-migrate","state-store","provider","schema"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}