hashicorp/terraform · critical
nil config passed to StateStoreProviderFactoryFromConfigStat
Error message
nil config passed to StateStoreProviderFactoryFromConfigState
What it means
Programmer-error panic in StateStoreProviderFactoryFromConfigState: callers must pass a non-nil *workdir.StateStoreConfigState. Passing nil panics immediately because the function dereferences cfgState.Provider. It guards against an internal coding mistake rather than user input.
Source
Thrown at internal/command/meta_backend.go:3018
Severity: hcl.DiagError,
Summary: "Provider unavailable",
Detail: fmt.Sprintf("The provider %s (%q) is required to initialize the %q state store, but the matching provider factory is missing. This is a bug in Terraform and should be reported.",
config.Provider.Name,
config.ProviderAddr,
config.Type,
),
Subject: &config.TypeRange,
})
}
return factory, diags
}
func (m *Meta) StateStoreProviderFactoryFromConfigState(cfgState *workdir.StateStoreConfigState) (providers.Factory, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
if cfgState == nil {
panic("nil config passed to StateStoreProviderFactoryFromConfigState")
}
if cfgState.Provider == nil || cfgState.Provider.Source.IsZero() {
// This should not happen; this data is populated when storing config state
return nil, diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Unknown provider used for state storage",
Detail: "Terraform could not find the provider used with the state_store. This is a bug in Terraform and should be reported.",
})
}
factories, err := m.ProviderFactories()
if err != nil {
// This may happen if the provider isn't present in the provider cache.
// This should be caught earlier by logic that diffs the config against the backend state file.
return nil, diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Provider unavailable",View on GitHub (pinned to d32a084675)
Solutions
- Report as a Terraform bug with the full command and config that triggered it.
- Ensure your working directory state (.terraform/terraform.tfstate) is not corrupted; re-run terraform init cleanly.
- If calling this method from tooling, always check for nil cfgState before invoking.
Example fix
// before
cfgState := loadedConfig() // may be nil
factory, diags := m.StateStoreProviderFactoryFromConfigState(cfgState)
// after
cfgState := loadedConfig()
if cfgState == nil {
return providers.Factory(nil), tfdiags.Diagnostics{}.Append(...)
}
factory, diags := m.StateStoreProviderFactoryFromConfigState(cfgState) Defensive patterns
Strategy: validation
Validate before calling
// Caller guard before invoking the Meta method.
if cfgState == nil {
return nil, tfdiags.Diagnostics{}.Append(tfdiags.Sourceless(tfdiags.Error, "no state store config", "..."))
}
return m.StateStoreProviderFactoryFromConfigState(cfgState) Prevention
- Never call StateStoreProviderFactoryFromConfigState with nil.
- If writing internal Terraform code, document the non-nil precondition.
- Re-run terraform init cleanly if the working-dir state is suspect.
When it happens
Trigger: An internal Terraform code path invoking StateStoreProviderFactoryFromConfigState(nil), e.g. when the state store config was never loaded or a refactored caller forgot to populate the pointer.
Common situations: Terraform internal bug after a refactor, custom command wrappers invoking this Meta method with a nil config, or a corrupted working-dir state file that produced nil on load.
Related errors
- errStateStoreInitDiag requires a non-nil reason argument
- init (determineIfProviderTrusted): unexpected provider locat
- Unexpected command type in confirmProviderIsTrusted; this is
- When installing providers described in the config Terraform
- confirmFunc must not be nil
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/d0ca8fbdb1f7f301.
Report an issue: GitHub.