{"record":{"id":"90ccf2d48125897e","repo":"hashicorp/terraform","slug":"state-store-is-not-valid-w","errorCode":null,"errorMessage":"state store is not valid: %w","messagePattern":"state store is not valid: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/workdir/statestore_config_state.go","lineNumber":61,"sourceCode":"func (s *StateStoreConfigState) Validate() error {\n\t// Are any bits of data totally missing?\n\tif s.Empty() {\n\t\treturn fmt.Errorf(\"attempted to encode a malformed backend state file; data is empty\")\n\t}\n\tif s.Type == \"\" {\n\t\treturn fmt.Errorf(\"attempted to encode a malformed backend state file; state store type is missing\")\n\t}\n\tif s.Provider == nil {\n\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","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/workdir/statestore_config_state.go#L43-L79","documentation":"At statestore_config_state.go:59 Validate calls s.Provider.Source.Validate() to check the provider's fully-qualified registry address (tfaddr.Provider) is well-formed. A failure (missing hostname/namespace, illegal characters, unknown format) is wrapped with 'state store is not valid:'.","triggerScenarios":"Provider.Source is a malformed tfaddr.Provider — e.g. 'terraform.io///foo' or a value failing the registry-address Validate rules.","commonSituations":"Hand-edited state file with a bad provider source string; a bug in address construction; a custom/dev provider address that doesn't parse.","solutions":["Inspect the wrapped error for the specific FQN problem it reports.","Re-run 'terraform init' so the provider source is recorded correctly from the dependency lock / required_providers.","Correct the provider source in your configuration's required_providers and re-init."],"exampleFix":"// before — .terraform/terraform.tfstate:\n\"provider\":{ \"source\":{ \"Type\":\"foo\", \"Namespace\":\"\", \"Hostname\":\"\" } }\nError: state store is not valid: ...\n\n// after — valid FQN, e.g. registry.terraform.io/hashicorp/remote\n$ rm -rf .terraform && terraform init","handlingStrategy":"validation","validationCode":"// Validate the provider FQN before assigning it to the state store.\nif err := providerSource.Validate(); err != nil {\n    return fmt.Errorf(\"provider source invalid: %w\", err)\n}\ns.Provider.Source = providerSource","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Construct provider addresses via tfaddr.ParseProviderSource so they are validated at parse time.","Never hand-type provider source strings into .terraform/terraform.tfstate.","Re-init to let Terraform record the address from required_providers."],"tags":["terraform","state-store","provider","registry-address"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}