{"record":{"id":"f14da44aa3b83cdd","repo":"hashicorp/terraform","slug":"state-store-is-not-valid-provider-version-data-is","errorCode":null,"errorMessage":"state store is not valid: provider version data is missing despite provider %s being managed by Terraform.","messagePattern":"state store is not valid: provider version data is missing despite provider (.+?) being managed by Terraform\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/workdir/statestore_config_state.go","lineNumber":70,"sourceCode":"\t\treturn fmt.Errorf(\"attempted to encode a malformed backend state file; provider data is missing\")\n\t}\n\tif s.ConfigRaw == nil {\n\t\treturn fmt.Errorf(\"attempted to encode a malformed backend state file; state_store configuration data is missing\")\n\t}\n\n\t// Validity of data that is there\n\terr := s.Provider.Source.Validate()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"state store is not valid: %w\", err)\n\t}\n\n\t// Version information is required if the provider isn't builtin or unmanaged by Terraform\n\tswitch s.ProviderSupplyMode {\n\tcase getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:\n\t\t// These modes do not require version information\n\tcase getproviders.ManagedByTerraform:\n\t\tif s.Provider.Version == nil {\n\t\t\treturn fmt.Errorf(\"state store is not valid: provider version data is missing despite provider %s being managed by Terraform.\", s.Provider.Source.ForDisplay())\n\t\t}\n\tdefault:\n\t\tpanic(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))\n\t}\n\n\treturn nil\n}\n\n// Config decodes the type-specific configuration object using the provided\n// schema and returns the result as a cty.Value.\n//\n// An error is returned if the stored configuration does not conform to the\n// given schema, or is otherwise invalid.\nfunc (s *StateStoreConfigState) Config(schema *configschema.Block) (cty.Value, error) {\n\tty := schema.ImpliedType()\n\tif s == nil {\n\t\treturn cty.NullVal(ty), nil\n\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/workdir/statestore_config_state.go#L52-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-editing .terraform/terraform.tfstate, third-party migration tooling, or development builds that wrote an incomplete record.","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."],"exampleFix":"rm .terraform/terraform.tfstate\nterraform init","handlingStrategy":"validation","validationCode":"// pre-flight: enforce version presence for managed mode\nif s.ProviderSupplyMode == getproviders.ManagedByTerraform && s.Provider.Version == nil {\n    return errors.New(\"ManagedByTerraform state_store requires Provider.Version; re-run `terraform init`\")\n}","typeGuard":"func (s *StateStoreConfigState) hasRequiredVersion() bool {\n    switch s.ProviderSupplyMode {\n    case getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:\n        return true\n    case getproviders.ManagedByTerraform:\n        return s.Provider != nil && s.Provider.Version != nil\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Run `terraform init` after changing supply modes.","Use DevOverride/BuiltIn only in dev; ManagedByTerraform in production."],"tags":["backend","state-store","provider-version","supply-mode","validate"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}