hashicorp/terraform · error
Failed to set state store configuration: %w
Error message
Failed to set state store configuration: %w
What it means
In Meta.stateStore_C_s (meta_backend.go:2272), Terraform calls StateStoreConfigState.SetConfig(storeConfigVal, b.ConfigSchema()) to serialize the decoded state_store configuration value into JSON against the backend/state-store schema. Failure means the state-store config value cannot be represented as JSON, almost always a state-store provider schema defect.
Source
Thrown at internal/command/meta_backend.go:2272
pVersion, vDiags := getStateStorageProviderVersion(c, opts.Locks) // pVersion will remain nil for builtin, dev override, and unmanaged providers.
diags = diags.Append(vDiags)
if vDiags.HasErrors() {
return nil, diags
}
s.Backend = nil // unset this; user may be running `terraform init -reconfigure` and there's a preexisting backend state file.
s.StateStore = &workdir.StateStoreConfigState{
Type: c.Type,
Hash: uint64(stateStoreHash),
Provider: &workdir.ProviderConfigState{
Source: &c.ProviderAddr,
Version: pVersion,
},
ProviderSupplyMode: c.ProviderSupplyMode,
}
err := s.StateStore.SetConfig(storeConfigVal, b.ConfigSchema())
if err != nil {
diags = diags.Append(fmt.Errorf("Failed to set state store configuration: %w", err))
return nil, diags
}
err = s.StateStore.Provider.SetConfig(providerConfigVal, b.ProviderSchema())
if err != nil {
diags = diags.Append(fmt.Errorf("Failed to set state store provider configuration: %w", err))
return nil, diags
}
// Verify that selected workspace exists in the state store.
if opts.Init && b != nil {
if err := m.selectWorkspace(b); err != nil {
if errors.Is(err, &errBackendNoExistingWorkspaces{}) {
ws, err := m.Workspace()
if err != nil {
diags = diags.Append(fmt.Errorf("Failed to check current workspace: %w", err))
return nil, diags
}View on GitHub (pinned to c9def3e214)
Solutions
- Read the wrapped `%w` to confirm it is a JSON/cty type failure, indicating a provider schema defect.
- Pin the state-store provider to a known-good version in the lock file and re-run `terraform init`.
- Reduce the state_store block to the minimum to isolate the failing attribute and report it to the provider maintainer.
- If recently upgraded Terraform core, try the previous Terraform version to rule out a core regression.
Defensive patterns
Strategy: validation
Validate before calling
// Validate the state_store config serializes against the backend schema before init writes it.
func stateStoreConfigSerializes(b backend.Backend, storeVal cty.Value) error {
st := &workdir.StateStoreConfigState{Type: "x"}
return st.SetConfig(storeVal, b.ConfigSchema())
} Prevention
- Pin a state-store provider version with a known-good schema in the lock file.
- Keep state_store blocks minimal and avoid attribute types the schema may not serialize.
- Test first-time state_store init in a scratch environment.
- Report provider schema defects upstream.
When it happens
Trigger: A state_store provider whose schema does not match the values it accepts, so the cty.Value fails JSON round-tripping; using an incompatible provider version with this Terraform build.
Common situations: State-store provider plugin with a schema regression; exotic/sensitive attribute types the JSON marshaler cannot encode.
Related errors
- Can't serialize backend configuration as JSON: %s
- Failed to set state store provider configuration: %w
- error converting output values to json: %s
- failed to marshal outputs to json: %w
- could not marshal output %s type: %w
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/87e33a4ab755b503.
Report an issue: GitHub.