{"record":{"id":"b38502b74f1e15fc","repo":"hashicorp/terraform","slug":"failed-to-set-state-store-configuration-w-b38502","errorCode":null,"errorMessage":"Failed to set state store configuration: %w","messagePattern":"Failed to set state store configuration: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/state_migrate.go","lineNumber":305,"sourceCode":"\t\tversion, err := providerreqs.GoVersionFromVersion(v)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to convert provider version to Go version: %s\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\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}","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/state_migrate.go#L287-L323","documentation":"Thrown during `terraform state migrate` to a state_store destination when bsf.StateStore.SetConfig(stateStoreConfigVal, dstB.ConfigSchema()) fails. SetConfig marshals the state-store config cty value to JSON against the state-store backend's ImpliedType; failure means the value does not conform to that schema. The %w carries the ctyjson marshal error naming the offending attribute/type.","triggerScenarios":"Running `terraform state migrate` where the state_store block's configuration value does not match the schema advertised by the destination state-store provider/backend (stateStoreInitFromConfig produced a value incompatible with dstB.ConfigSchema()).","commonSituations":"State-store block with attributes the provider does not recognise; mismatched state-store provider version; typo'd or deprecated attribute in the state_store block; schema drift between provider versions.","solutions":["Read the wrapped %w: it identifies the exact attribute/type mismatch versus the state-store schema.","Correct the state_store block to use only attributes documented by the state-store provider.","Re-run `terraform init -upgrade` to pull a state-store provider whose schema matches the config.","Pin the state-store provider to the version declared in required_providers to avoid silent schema changes."],"exampleFix":"# before\nterraform {\n  state_store \"foo\" {\n    unkown_attr = \"x\"  # typo, not in schema\n  }\n}\n\n# after\nterraform {\n  state_store \"foo\" {\n    region = \"us-east-1\"\n  }\n}","handlingStrategy":"validation","validationCode":"// verify a state_store config value conforms to the state-store schema\nfunc validateStateStoreConfig(val cty.Value, schema *configschema.Block) error {\n    _, err := ctyjson.Marshal(val, schema.ImpliedType())\n    return err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match the state_store block attributes to the state-store provider's docs.","Run `terraform init -upgrade` to align the provider schema with config.","Pin the state-store provider version explicitly.","Validate config before attempting a state migration."],"tags":["state-migrate","state-store","schema","configuration"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}