hashicorp/terraform · error
Failed to set state store provider configuration: %w
Error message
Failed to set state store provider configuration: %w
What it means
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.
Source
Thrown at internal/command/meta_backend.go:2278
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
}
if ws == backend.DefaultStateName {
// If the default workspace is selected, no workspaces existing _may_ be expected.
// It's valid for the default workspace's state to not be created until the first apply takes place.
// However, it could be that the user is configuring their working directory for the first time but
// they expect pre-existing state to be in the store from previous actions. In that case, the userView on GitHub (pinned to c9def3e214)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Validate the nested provider config serializes against the provider schema before init writes it.
func stateStoreProviderConfigSerializes(b backend.Backend, providerVal cty.Value) error {
if b.ProviderSchema() == nil { return fmt.Errorf("no provider schema available") }
st := &workdir.StateStoreConfigState{Type: "x", Provider: &workdir.ProviderConfigState{}}
return st.Provider.SetConfig(providerVal, b.ProviderSchema())
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Provider plugin schema bug; using TF_REATTACH_PROVIDERS or dev overrides supplying a provider with a mismatched schema; provider version regression.
Related errors
- Failed to set state store configuration: %w
- Can't serialize backend configuration as JSON: %s
- Failed to set state store provider configuration: %w
- missing provider schema
- Failed to negotiate acceptable chunk size. Expected size > 0
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/5ffde5fe357203a2.
Report an issue: GitHub.