hashicorp/terraform · critical

State store provider is missing from required providers but

Error message

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!

What it means

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.

Source

Thrown at internal/configs/state_store.go:202

			tfdiags.Error,
			"Inconsistent dependency lock file",
			fmt.Sprintf(`The provider dependency used for state storage is missing from the lock file despite being present in the current configuration:
  - provider %s: required by this configuration but no version is selected

To make the initial dependency selections that will initialize the dependency lock file, run:
  terraform init`,
				ss.ProviderAddr,
			),
		))
		return diags
	}

	req, ok := reqs.RequiredProviders[ss.ProviderAddr.Type]
	if !ok {
		// The provider used for state storage is not in the required providers list.
		// This should have been identified when the block was parsed, so if we get here
		// it suggests that upstream code is swallowing that error.
		panic("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!")
	}

	// Is the provider in the lock file, and is it an appropriate version matching the constraints in required_providers?

	lock := depLocks.Provider(ss.ProviderAddr)
	constraints := providerreqs.MustParseVersionConstraints(req.Requirement.Required.String())
	if lock == nil {
		log.Printf("[TRACE] StateStore.VerifyDependencySelections: provider %s has no lock file entry to satisfy %q", ss.ProviderAddr, providerreqs.VersionConstraintsString(constraints))
		return diags.Append(tfdiags.Sourceless(
			tfdiags.Error,
			"Inconsistent dependency lock file",
			fmt.Sprintf(`The provider dependency used for state storage recorded in the lock file is inconsistent with the current configuration:
  - provider %s: required by this configuration but no version is selected

To make the initial dependency selections that will initialize the dependency lock file, run:
  terraform init`,
				ss.ProviderAddr,
			),

View on GitHub (pinned to c9def3e214)

Solutions

  1. Explicitly declare the state-store provider in a required_providers block with the exact source address used by state_store.
  2. Report as a Terraform bug with the state_store and required_providers configuration.
  3. Verify provider source address spelling/namespace matches between required_providers and state_store.
  4. Reproduce on the latest stable Terraform and downgrade if needed.

Example fix

// before: state_store provider not (correctly) in required_providers
terraform {
  required_providers {
    mycloud = { source = "myorg/mycloud" }
  }
  state_store "remote" {
    provider = "myorg/wrongcloud"   # mismatch -> panics if parser missed it
  }
}

// after: align the source address
terraform {
  required_providers {
    mycloud = { source = "myorg/mycloud" }
  }
  state_store "remote" {
    provider = "myorg/mycloud"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// HCL: ensure the state_store provider is declared in required_providers
terraform {
  required_providers {
    pss = { source = "myorg/statestore" }
  }
  state_store "remote" {
    provider = "myorg/statestore"
  }
}

Type guard

// Go: confirm the state-store provider source is registered
func providerRegistered(addr string, reqs *configs.RequiredProviders) bool {
	_, ok := reqs.RequiredProviders[addr]
	return ok
}

Try / catch

// Go: recover and downgrade panic to diagnostic
defer func() {
	if r := recover(); r != nil {
		diags = diags.Append(fmt.Errorf("state-store provider missing from required_providers: %v", r))
	}
}()
ss.VerifyDependencySelection(depLocks, reqs, supplyMode)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/04f432665d1c331a. Report an issue: GitHub.