hashicorp/terraform · error

state store is not valid: %w

Error message

state store is not valid: %w

What it means

At statestore_config_state.go:59 Validate calls s.Provider.Source.Validate() to check the provider's fully-qualified registry address (tfaddr.Provider) is well-formed. A failure (missing hostname/namespace, illegal characters, unknown format) is wrapped with 'state store is not valid:'.

Source

Thrown at internal/command/workdir/statestore_config_state.go:61

func (s *StateStoreConfigState) Validate() error {
	// Are any bits of data totally missing?
	if s.Empty() {
		return fmt.Errorf("attempted to encode a malformed backend state file; data is empty")
	}
	if s.Type == "" {
		return fmt.Errorf("attempted to encode a malformed backend state file; state store type is missing")
	}
	if s.Provider == nil {
		return fmt.Errorf("attempted to encode a malformed backend state file; provider data is missing")
	}
	if s.ConfigRaw == nil {
		return fmt.Errorf("attempted to encode a malformed backend state file; state_store configuration data is missing")
	}

	// Validity of data that is there
	err := s.Provider.Source.Validate()
	if err != nil {
		return fmt.Errorf("state store is not valid: %w", err)
	}

	// Version information is required if the provider isn't builtin or unmanaged by Terraform
	switch s.ProviderSupplyMode {
	case getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:
		// These modes do not require version information
	case getproviders.ManagedByTerraform:
		if s.Provider.Version == nil {
			return fmt.Errorf("state store is not valid: provider version data is missing despite provider %s being managed by Terraform.", s.Provider.Source.ForDisplay())
		}
	default:
		panic(fmt.Sprintf("State store provider %q (%s) has unknown supply mode %q. This is a bug in Terraform and should be reported.", s.Provider.Source.Type, s.Provider.Source.ForDisplay(), s.ProviderSupplyMode))
	}

	return nil
}

// Config decodes the type-specific configuration object using the provided

View on GitHub (pinned to c9def3e214)

Solutions

  1. Inspect the wrapped error for the specific FQN problem it reports.
  2. Re-run 'terraform init' so the provider source is recorded correctly from the dependency lock / required_providers.
  3. Correct the provider source in your configuration's required_providers and re-init.

Example fix

// before — .terraform/terraform.tfstate:
"provider":{ "source":{ "Type":"foo", "Namespace":"", "Hostname":"" } }
Error: state store is not valid: ...

// after — valid FQN, e.g. registry.terraform.io/hashicorp/remote
$ rm -rf .terraform && terraform init
Defensive patterns

Strategy: validation

Validate before calling

// Validate the provider FQN before assigning it to the state store.
if err := providerSource.Validate(); err != nil {
    return fmt.Errorf("provider source invalid: %w", err)
}
s.Provider.Source = providerSource

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Provider.Source is a malformed tfaddr.Provider — e.g. 'terraform.io///foo' or a value failing the registry-address Validate rules.

Common situations: Hand-edited state file with a bad provider source string; a bug in address construction; a custom/dev provider address that doesn't parse.

Related errors


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