{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/state_migrate.go","lineNumber":308,"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":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/state_migrate.go#L290-L326","documentation":"Thrown during state-store migration when bsf.StateStore.SetConfig(stateStoreConfigVal, dstB.ConfigSchema()) fails to serialize the state-store (not provider) configuration. Mirrors [747] but for the `state_store` block rather than `backend` block. Uses %w so the underlying error is preserved.","triggerScenarios":"The state_store block's hcl config value does not match dstB.ConfigSchema(): missing required attributes, type mismatches, unknown values, or schema is empty because the state-store provider wasn't loaded correctly.","commonSituations":"State-store block missing required fields; `required_providers` does not include the state-store provider at the right source address; typo'd attribute names; variable interpolation left unresolved because state_store blocks are evaluated early.","solutions":["Read the wrapped err for the exact attribute/schema mismatch.","Confirm the state-store provider is in required_providers and was downloaded (`terraform providers` shows it).","Cross-check each attribute against the state-store provider's docs.","Run `terraform init -upgrade` to refresh the schema from a freshly downloaded provider binary."],"exampleFix":"// before\n terraform {\n   state_store \"xyz\" {\n     cluster = \"prod\"\n   }\n }\n\n// after\n terraform {\n   state_store \"xyz\" {\n     cluster = \"prod\"\n     region  = \"us-east-1\"\n   }\n }","handlingStrategy":"validation","validationCode":"// Pre-validate state_store block schema.\nif _, diags := dstB.ConfigSchema().Validate(stateStoreConfigVal); diags.HasErrors() {\n    return diags\n}","typeGuard":null,"tryCatchPattern":"if err := bsf.StateStore.SetConfig(stateStoreConfigVal, dstB.ConfigSchema()); err != nil {\n    diags = diags.Append(fmt.Errorf(\"Failed to set state store configuration: %w\", err))\n    view.Diagnostics(diags)\n    hintInvalidStateStoreBlock(view, rootMod.StateStore.Type)\n    return 1\n}","preventionTips":["Cross-check state_store block attributes against the provider's docs.","Ensure required_providers has the state-store provider before migration.","Avoid variable interpolation in state_store that depends on values resolved later.","Run `terraform init -upgrade` to get a fresh provider schema."],"tags":["terraform","state-migration","state-store","config","schema","hcl"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}