{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/state_store.go#L184-L220","documentation":"A panic in `StateStore.VerifyDependencySelection` (internal/configs/state_store.go:202) when the state-store provider's source address is absent from the `reqs.RequiredProviders` map. The comment explains this should have been caught during config parsing, so reaching this point means upstream parsing silently swallowed the error. It panics asking the user to report it.","triggerScenarios":"A configuration with a `state_store` block referencing a provider that is not listed in `required_providers`, but the earlier validation that should have rejected this did not fire (a parsing bug). Normally the missing provider is reported as a config diagnostic, not a panic.","commonSituations":"A bug in state_store block parsing introduced during provider-state-store feature development; config that declares a state_store provider via an unusual source address that the parser fails to normalize into RequiredProviders.","solutions":["Explicitly declare the state-store provider in a required_providers block with the exact source address used by state_store.","Report as a Terraform bug with the state_store and required_providers configuration.","Verify provider source address spelling/namespace matches between required_providers and state_store.","Reproduce on the latest stable Terraform and downgrade if needed."],"exampleFix":"// before: state_store provider not (correctly) in required_providers\nterraform {\n  required_providers {\n    mycloud = { source = \"myorg/mycloud\" }\n  }\n  state_store \"remote\" {\n    provider = \"myorg/wrongcloud\"   # mismatch -> panics if parser missed it\n  }\n}\n\n// after: align the source address\nterraform {\n  required_providers {\n    mycloud = { source = \"myorg/mycloud\" }\n  }\n  state_store \"remote\" {\n    provider = \"myorg/mycloud\"\n  }\n}","handlingStrategy":"validation","validationCode":"// HCL: ensure the state_store provider is declared in required_providers\nterraform {\n  required_providers {\n    pss = { source = \"myorg/statestore\" }\n  }\n  state_store \"remote\" {\n    provider = \"myorg/statestore\"\n  }\n}","typeGuard":"// Go: confirm the state-store provider source is registered\nfunc providerRegistered(addr string, reqs *configs.RequiredProviders) bool {\n\t_, ok := reqs.RequiredProviders[addr]\n\treturn ok\n}","tryCatchPattern":"// Go: recover and downgrade panic to diagnostic\ndefer func() {\n\tif r := recover(); r != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"state-store provider missing from required_providers: %v\", r))\n\t}\n}()\nss.VerifyDependencySelection(depLocks, reqs, supplyMode)","preventionTips":["Always declare the state_store provider in required_providers with the exact source address.","Keep source address spelling identical across required_providers and state_store.","Report as a bug if the parser should have caught the missing provider earlier.","Run `terraform validate` after editing state_store blocks."],"tags":["terraform","state-store","provider-state-store","panic","required-providers","internal-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}