{"record":{"id":"04f432665d1c331a","repo":"hashicorp/terraform","slug":"state-store-provider-is-missing-from-required-prov","errorCode":null,"errorMessage":"State store provider is missing from required providers but this was not caught during config parsing, which is a bug in Terraform; please report it!","messagePattern":"State store provider is missing from required providers but this was not caught during config parsing, which is a bug in Terraform; please report it!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/configs/state_store.go","lineNumber":202,"sourceCode":"\t\t\ttfdiags.Error,\n\t\t\t\"Inconsistent dependency lock file\",\n\t\t\tfmt.Sprintf(`The provider dependency used for state storage is missing from the lock file despite being present in the current configuration:\n  - provider %s: required by this configuration but no version is selected\n\nTo make the initial dependency selections that will initialize the dependency lock file, run:\n  terraform init`,\n\t\t\t\tss.ProviderAddr,\n\t\t\t),\n\t\t))\n\t\treturn diags\n\t}\n\n\treq, ok := reqs.RequiredProviders[ss.ProviderAddr.Type]\n\tif !ok {\n\t\t// The provider used for state storage is not in the required providers list.\n\t\t// This should have been identified when the block was parsed, so if we get here\n\t\t// it suggests that upstream code is swallowing that error.\n\t\tpanic(\"State store provider is missing from required providers but this was not caught during config parsing, which is a bug in Terraform; please report it!\")\n\t}\n\n\t// Is the provider in the lock file, and is it an appropriate version matching the constraints in required_providers?\n\n\tlock := depLocks.Provider(ss.ProviderAddr)\n\tconstraints := providerreqs.MustParseVersionConstraints(req.Requirement.Required.String())\n\tif lock == nil {\n\t\tlog.Printf(\"[TRACE] StateStore.VerifyDependencySelections: provider %s has no lock file entry to satisfy %q\", ss.ProviderAddr, providerreqs.VersionConstraintsString(constraints))\n\t\treturn diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Inconsistent dependency lock file\",\n\t\t\tfmt.Sprintf(`The provider dependency used for state storage recorded in the lock file is inconsistent with the current configuration:\n  - provider %s: required by this configuration but no version is selected\n\nTo make the initial dependency selections that will initialize the dependency lock file, run:\n  terraform init`,\n\t\t\t\tss.ProviderAddr,\n\t\t\t),","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/configs/state_store.go#L184-L220","documentation":"StateStore.VerifyDependencySelection (internal/configs/state_store.go:197) looks up the state-store provider in reqs.RequiredProviders by its type and panics if missing. The comment states the config parser should already have rejected a state_store block whose provider is not declared in required_providers, so reaching here means an upstream error was swallowed.","triggerScenarios":"A state_store block names a provider that is absent from the required_providers map passed to VerifyDependencySelection, yet no diagnostic was surfaced — e.g. config parsing returned a partial result after discarding an error, or the RequiredProviders map was built from a stale/different config than the state_store block.","commonSituations":"A state_store block referencing a provider whose required_providers entry was removed or renamed between parse and verify; a custom config-loading path that drops diagnostics; a typo/mismatch between the state_store provider type and the required_providers local name.","solutions":["Confirm the state_store block's provider matches a required_providers entry in the same module; run 'terraform validate' to surface the parse-time diagnostic that should have prevented this.","If you maintain a custom code path that calls VerifyDependencySelection, ensure you propagate ALL parse diagnostics instead of discarding them.","Re-run 'terraform init' after fixing required_providers so the dependency selection is consistent.","Report upstream: include the config (state_store + required_providers) so the swallowed-diagnostic path can be fixed."],"exampleFix":"// before\nreq, ok := reqs.RequiredProviders[ss.ProviderAddr.Type]\nif !ok {\n    panic(\"State store provider is missing from required providers but this was not caught during config parsing, ...\")\n}\n\n// after (surface a diagnostic instead of crashing)\nreq, ok := reqs.RequiredProviders[ss.ProviderAddr.Type]\nif !ok {\n    return diags.Append(tfdiags.Sourceless(tfdiags.Error,\n        \"State store provider not declared\",\n        fmt.Sprintf(\"%s must be declared in required_providers.\", ss.ProviderAddr)))\n}","handlingStrategy":"validation","validationCode":"// Confirm the state-store provider is declared before verifying selections.\nfunc stateStoreProviderDeclared(reqs *configs.RequiredProviders, addr tfaddr.Provider) bool {\n    if reqs == nil {\n        return false\n    }\n    _, ok := reqs.RequiredProviders[addr.Type]\n    return ok\n}\nif !stateStoreProviderDeclared(reqs, ss.ProviderAddr) {\n    return diags.Append(tfdiags.Sourceless(tfdiags.Error,\n        \"State store provider not declared\",\n        fmt.Sprintf(\"Add %s to required_providers.\", ss.ProviderAddr)))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare the state-store provider in a required_providers block of the same module.","Run 'terraform validate' after editing state_store / required_providers to catch mismatches at parse time.","If you maintain a custom config-loading path, never discard parse diagnostics before calling VerifyDependencySelection."],"tags":["panic","state-store","required-providers","config-parsing","internal-bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}