hashicorp/terraform · critical
expected one provider requirement for the destination state
Error message
expected one provider requirement for the destination state store provider %q, but received empty data about required providers.
What it means
This panic fires in getDestinationStateStoreProviderRequirements when the passed *configs.RequiredProviders is nil. A state_store block must declare its backing provider under required_providers, so a nil pointer means the caller (state push/list, or migration setup) failed to load/forward the configuration's required_providers block.
Source
Thrown at internal/command/state_migrate.go:456
if err := sMgr.WriteState(s); err != nil {
diags = diags.Append(errBackendWriteSavedDiag(err))
return diags
}
if err := sMgr.PersistState(); err != nil {
diags = diags.Append(errBackendWriteSavedDiag(err))
return diags
}
return diags
}
func (c *StateMigrateCommand) getDestinationStateStoreProviderRequirements(provider addrs.Provider, configReqs *configs.RequiredProviders) (providerreqs.Requirements, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
req := make(providerreqs.Requirements, 1)
if configReqs == nil {
panic(fmt.Sprintf("expected one provider requirement for the destination state store provider %q, but received empty data about required providers.", provider))
}
for _, providerReq := range configReqs.RequiredProviders {
if providerReq.Type.Equals(provider) {
con, err := providerreqs.ParseVersionConstraints(providerReq.Requirement.Required.String())
if err != nil {
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid version constraint syntax for state store provider",
// The errors returned by ParseVersionConstraint already include
// the section of input that was incorrect, so we don't need to
// include that here.
Detail: fmt.Sprintf("Incorrect version constraint syntax: %s.", err.Error()),
Subject: providerReq.Requirement.DeclRange.Ptr(),
})
}
req[providerReq.Type] = con
}View on GitHub (pinned to d32a084675)
Solutions
- In your configuration, ensure every state_store block has a corresponding required_providers entry naming the same provider address (e.g. registry.terraform.io/hashicorp/terraform-state-store-mysql).
- Run `terraform init` after editing the config so the required_providers block is parsed and forwarded to the state-store machinery.
- If you maintain the calling code, guard with `if configReqs == nil { return diags-emitting error }` instead of letting it reach the panic.
Example fix
// before
required_providers { /* missing the state-store provider */ }
state_store "mysql" { provider = "..." }
// after
required_providers {
tfstate-mysql = {
source = "registry.terraform.io/hashicorp/terraform-state-store-mysql"
version = ">= 0.1.0"
}
}
state_store "mysql" { provider = "..." } Defensive patterns
Strategy: validation
Validate before calling
// Caller-side guard before invoking state-store provider resolution.
if configReqs == nil || len(configReqs.RequiredProviders) == 0 {
return fmt.Errorf("configuration has no required_providers for state store %q", provider)
} Type guard
// n/a — pointer null-check
Prevention
- Always pair a `state_store` block with a matching `required_providers` entry in the same module.
- Run `terraform init` after adding a state_store block to validate the configuration.
- Lint configurations for state_store blocks missing a sibling required_providers entry.
When it happens
Trigger: State migration (terraform state migrate, or state push to a configured state_store) where the configuration containing the state_store block could not supply its RequiredProviders map. Concretely: the state_store provider lookup is invoked before config parsing finishes, or the config has a state_store block with no sibling required_providers block at all.
Common situations: A user writes a `state_store "..." { ... }` block but omits the matching `required_providers` entry, or a Terraform internal refactor passes a nil configReqs through this path. Triggered during state-migration setup, not during normal plan/apply.
Related errors
- expected exactly one provider requirement for the destinatio
- expected exactly one provider requirement for the destinatio
- failed to encode main index: %s
- failed to encode version index: %s
- backendDiags.Err()
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/56753e0a20471c60.
Report an issue: GitHub.