hashicorp/terraform · error
state store is not valid: provider version data is missing…
Error message
state store is not valid: provider version data is missing despite provider %s being managed by Terraform.
What it means
StateStoreConfigState.Validate(): ProviderSupplyMode is getproviders.ManagedByTerraform but Provider.Version is nil. Managed mode requires Terraform to install and pin the provider, so a missing version is illegal. Other modes (BuiltIn, Reattached, DevOverride) intentionally skip version info.
Solutions
- Run `terraform init -upgrade` to re-resolve and write the provider version.
- Manually set ProviderSupplyMode to the correct mode for your setup (e.g. DevOverride for local dev).
- Delete the file and re-init.
Example fix
rm .terraform/terraform.tfstate terraform init
Defensive patterns
Strategy: validation
Validate before calling
// pre-flight: enforce version presence for managed mode
if s.ProviderSupplyMode == getproviders.ManagedByTerraform && s.Provider.Version == nil {
return errors.New("ManagedByTerraform state_store requires Provider.Version; re-run `terraform init`")
} Type guard
func (s *StateStoreConfigState) hasRequiredVersion() bool {
switch s.ProviderSupplyMode {
case getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:
return true
case getproviders.ManagedByTerraform:
return s.Provider != nil && s.Provider.Version != nil
}
return false
} Prevention
- Run `terraform init` after changing supply modes.
- Use DevOverride/BuiltIn only in dev; ManagedByTerraform in production.
When it happens
Trigger: A state_store record tagged as managed-by-terraform but with no version field — possible if the file was written by a buggy build, hand-edited, or partially restored from backup.
Common situations: Hand-editing .terraform/terraform.tfstate, third-party migration tooling, or development builds that wrote an incomplete record.
Related errors
- attempted to encode a malformed backend state file…
- attempted to encode a malformed backend state file; state…
- attempted to encode a malformed backend state file…
- attempted to encode a malformed backend state file; data is…
- error when preparing state store config for planfile
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/f14da44aa3b83cdd.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/workdir/statestore_config_state.go:70
return fmt.Errorf("attempted to encode a malformed backend state file; provider data is missing")
}
if s.ConfigRaw == nil {
return fmt.Errorf("attempted to encode a malformed backend state file; state_store configuration data is missing")
}
// Validity of data that is there
err := s.Provider.Source.Validate()
if err != nil {
return fmt.Errorf("state store is not valid: %w", err)
}
// Version information is required if the provider isn't builtin or unmanaged by Terraform
switch s.ProviderSupplyMode {
case getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:
// These modes do not require version information
case getproviders.ManagedByTerraform:
if s.Provider.Version == nil {
return fmt.Errorf("state store is not valid: provider version data is missing despite provider %s being managed by Terraform.", s.Provider.Source.ForDisplay())
}
default:
panic(fmt.Sprintf("State store provider %q (%s) has unknown supply mode %q. This is a bug in Terraform and should be reported.", s.Provider.Source.Type, s.Provider.Source.ForDisplay(), s.ProviderSupplyMode))
}
return nil
}
// Config decodes the type-specific configuration object using the provided
// schema and returns the result as a cty.Value.
//
// An error is returned if the stored configuration does not conform to the
// given schema, or is otherwise invalid.
func (s *StateStoreConfigState) Config(schema *configschema.Block) (cty.Value, error) {
ty := schema.ImpliedType()
if s == nil {
return cty.NullVal(ty), nil
}View on GitHub (pinned to d32a084675)