{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/workdir/statestore_config_state.go#L52-L88","documentation":"When ProviderSupplyMode == ManagedByTerraform (statestore_config_state.go:68), the provider's version must be recorded because Terraform installed and locks it. A nil Provider.Version is rejected at line 69 since plan/state round-trips need a concrete version to write into the plan file (see PlanData at statestore_config_state.go:141).","triggerScenarios":"Validate() reaches the ManagedByTerraform case (line 68) with s.Provider.Version == nil.","commonSituations":"State store file written before version tracking was implemented; a bug that failed to capture the installed provider version; partial state_store data after a failed init.","solutions":["Re-run 'terraform init' so the provider is installed and its version recorded in the state_store record.","Verify the provider is actually installed ('terraform providers').","If it persists on a released Terraform, report the bug."],"exampleFix":"// before\ns.ProviderSupplyMode = getproviders.ManagedByTerraform\ns.Provider = &ProviderConfigState{Source: addr} // Version nil -> error 772\n\n// after\nv, _ := version.NewVersion(\"1.2.3\")\ns.Provider.Version = v","handlingStrategy":"validation","validationCode":"// For ManagedByTerraform providers, require a version before encoding.\nif s.ProviderSupplyMode == getproviders.ManagedByTerraform && s.Provider.Version == nil {\n    return errors.New(\"managed provider requires a version\")\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["After installing a managed state-store provider, capture its version (from the dependency lock or install result) into Provider.Version.","Re-run 'terraform init' if the version field is missing.","Add a test asserting ManagedByTerraform state stores always carry a version."],"tags":["terraform","state-store","provider","version"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}