{"record":{"id":"5ffde5fe357203a2","repo":"hashicorp/terraform","slug":"failed-to-set-state-store-provider-configuration","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/meta_backend.go","lineNumber":2278,"sourceCode":"\ts.Backend = nil // unset this; user may be running `terraform init -reconfigure` and there's a preexisting backend state file.\n\ts.StateStore = &workdir.StateStoreConfigState{\n\t\tType: c.Type,\n\t\tHash: uint64(stateStoreHash),\n\t\tProvider: &workdir.ProviderConfigState{\n\t\t\tSource:  &c.ProviderAddr,\n\t\t\tVersion: pVersion,\n\t\t},\n\t\tProviderSupplyMode: c.ProviderSupplyMode,\n\t}\n\terr := s.StateStore.SetConfig(storeConfigVal, b.ConfigSchema())\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store configuration: %w\", err))\n\t\treturn nil, diags\n\t}\n\n\terr = s.StateStore.Provider.SetConfig(providerConfigVal, b.ProviderSchema())\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store provider configuration: %w\", err))\n\t\treturn nil, diags\n\t}\n\n\t// Verify that selected workspace exists in the state store.\n\tif opts.Init && b != nil {\n\t\tif err := m.selectWorkspace(b); err != nil {\n\t\t\tif errors.Is(err, &errBackendNoExistingWorkspaces{}) {\n\t\t\t\tws, err := m.Workspace()\n\t\t\t\tif err != nil {\n\t\t\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to check current workspace: %w\", err))\n\t\t\t\t\treturn nil, diags\n\t\t\t\t}\n\n\t\t\t\tif ws == backend.DefaultStateName {\n\t\t\t\t\t// If the default workspace is selected, no workspaces existing _may_ be expected.\n\t\t\t\t\t// It's valid for the default workspace's state to not be created until the first apply takes place.\n\t\t\t\t\t// However, it could be that the user is configuring their working directory for the first time but\n\t\t\t\t\t// they expect pre-existing state to be in the store from previous actions. In that case, the user","sourceCodeStart":2260,"sourceCodeEnd":2296,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend.go#L2260-L2296","documentation":"In Meta.stateStore_C_s (meta_backend.go:2278), immediately after setting the state-store config, Terraform sets the nested PROVIDER configuration via StateStore.Provider.SetConfig(providerConfigVal, b.ProviderSchema()). Failure means the provider portion of the state_store block could not be serialized to JSON against the provider schema.","triggerScenarios":"The state_store provider's nested provider schema does not faithfully describe accepted values, so the provider config value fails JSON round-tripping; an incompatible provider binary.","commonSituations":"Provider plugin schema bug; using TF_REATTACH_PROVIDERS or dev overrides supplying a provider with a mismatched schema; provider version regression.","solutions":["Confirm from the wrapped `%w` that it is a JSON/cty type error (a provider schema defect, not a typo).","Pin a known-good provider version in .terraform.lock.hcl and re-run init.","If using dev overrides / TF_REATTACH_PROVIDERS, ensure the attached provider binary's schema matches what core expects.","Minimize the nested provider {} block to find the offending attribute and report upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the nested provider config serializes against the provider schema before init writes it.\nfunc stateStoreProviderConfigSerializes(b backend.Backend, providerVal cty.Value) error {\n    if b.ProviderSchema() == nil { return fmt.Errorf(\"no provider schema available\") }\n    st := &workdir.StateStoreConfigState{Type: \"x\", Provider: &workdir.ProviderConfigState{}}\n    return st.Provider.SetConfig(providerVal, b.ProviderSchema())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure dev-override/TF_REATTACH_PROVIDERS providers expose a schema matching core expectations.","Pin the provider version in .terraform.lock.hcl to one with a valid schema.","Keep the nested provider {} block minimal.","Report provider schema mismatches to the provider maintainer."],"tags":["state-store","provider","schema","json","serialization"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}