{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/workdir/statestore_config_state.go#L43-L79","documentation":"StateStoreConfigState.Validate() called Provider.Source.Validate() (the getproviders SourceAddress validator) and it failed; the %w wraps that error. This is the state_store's nested provider source address being malformed (e.g. invalid hostname, illegal characters in namespace/name).","triggerScenarios":"Constructing a state_store whose provider source is something like `foo/bar baz` (space), `terraform-` (trailing dash), or an unparseable FQN. Surfaces on `terraform init`/plan when the state file is being validated.","commonSituations":"Hand-edited backend state with a typo'd provider source, a fork/experiment using a non-standard source address, or copy-paste from docs with smart-quotes.","solutions":["Inspect the wrapped error for the specific SourceAddress validation rule that failed.","Fix the provider source FQN in the state_store block (e.g. `registry.opentofu.org/namespace/name`).","Re-run `terraform init` after correcting the configuration."],"exampleFix":"# before — invalid provider source\nterraform {\n  state_store {\n    provider = \"foo bar/baz\"\n  }\n}\n\n# after — valid FQN\nterraform {\n  state_store {\n    provider = \"registry.opentofu.org/hashicorp/kubernetes\"\n  }\n}","handlingStrategy":"validation","validationCode":"// pre-flight: validate provider source before encode\nif s.Provider != nil {\n    if err := s.Provider.Source.Validate(); err != nil {\n        return fmt.Errorf(\"fix provider source FQN in state_store block: %w\", err)\n    }\n}","typeGuard":"func isValidProviderSource(s getproviders.Source) bool { return s.Validate() == nil }","tryCatchPattern":null,"preventionTips":["Use canonical provider FQNs (registry.opentofu.org/namespace/name).","Avoid smart-quotes when copy-pasting source addresses."],"tags":["backend","state-store","provider","source-address","validate"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}