hashicorp/terraform · error

state store is not valid: provider version data is missing d

Error message

state store is not valid: provider version data is missing despite provider %s being managed by Terraform.

What it means

When ProviderSupplyMode == ManagedByTerraform (statestore_config_state.go:68), the provider's version must be recorded because Terraform installed and locks it. A nil Provider.Version is rejected at line 69 since plan/state round-trips need a concrete version to write into the plan file (see PlanData at statestore_config_state.go:141).

Source

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

		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
// schema and returns the result as a cty.Value.
//
// An error is returned if the stored configuration does not conform to the
// given schema, or is otherwise invalid.
func (s *StateStoreConfigState) Config(schema *configschema.Block) (cty.Value, error) {
	ty := schema.ImpliedType()
	if s == nil {
		return cty.NullVal(ty), nil
	}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run 'terraform init' so the provider is installed and its version recorded in the state_store record.
  2. Verify the provider is actually installed ('terraform providers').
  3. If it persists on a released Terraform, report the bug.

Example fix

// before
s.ProviderSupplyMode = getproviders.ManagedByTerraform
s.Provider = &ProviderConfigState{Source: addr} // Version nil -> error 772

// after
v, _ := version.NewVersion("1.2.3")
s.Provider.Version = v
Defensive patterns

Strategy: validation

Validate before calling

// For ManagedByTerraform providers, require a version before encoding.
if s.ProviderSupplyMode == getproviders.ManagedByTerraform && s.Provider.Version == nil {
    return errors.New("managed provider requires a version")
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Validate() reaches the ManagedByTerraform case (line 68) with s.Provider.Version == nil.

Common situations: State store file written before version tracking was implemented; a bug that failed to capture the installed provider version; partial state_store data after a failed init.

Related errors


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