hashicorp/terraform · error

no schema found for %s (in provider %s)

Error message

no schema found for %s (in provider %s)

What it means

In marshalResourceChange, schemas.ResourceTypeConfig(...).Body == nil means Terraform has no config schema for the resource type from the named provider. Without the schema it cannot decode the change or render before/after values, so it aborts. This is the most common schema-availability error in plan rendering.

Source

Thrown at internal/command/jsonplan/plan.go:462

	return ret, nil
}

func marshalResourceChange(rc *plans.ResourceInstanceChangeSrc, schemas *terraform.Schemas) (ResourceChange, error) {
	var r ResourceChange
	addr := rc.Addr
	r.Address = addr.String()
	if !addr.Equal(rc.PrevRunAddr) {
		r.PreviousAddress = rc.PrevRunAddr.String()
	}

	schema := schemas.ResourceTypeConfig(
		rc.ProviderAddr.Provider,
		addr.Resource.Resource.Mode,
		addr.Resource.Resource.Type,
	)
	if schema.Body == nil {
		return r, fmt.Errorf("no schema found for %s (in provider %s)", r.Address, rc.ProviderAddr.Provider)
	}

	changeV, err := rc.Decode(schema)
	if err != nil {
		return r, err
	}
	// We drop the marks from the change, as decoding is only an
	// intermediate step to re-encode the values as json
	changeV.Before, _ = changeV.Before.UnmarkDeep()
	changeV.After, _ = changeV.After.UnmarkDeep()

	var before, after []byte
	var beforeSensitive, afterSensitive []byte
	var afterUnknown cty.Value

	if changeV.Before != cty.NilVal {
		before, err = ctyjson.Marshal(changeV.Before, changeV.Before.Type())
		if err != nil {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Run `terraform init` to install the provider that defines the resource type.
  2. Pin or upgrade to a provider version that still defines the resource (check the provider's docs/changelog).
  3. If the resource was removed from config intentionally, remove it from state with `terraform state rm`.
  4. Verify provider source addresses in .terraform.lock.hcl match required_providers.

Example fix

# before: provider missing the type
terraform show -json p.tfplan  # no schema found for aws_example (in provider registry.../aws)

# after: install/upgrade the provider
terraform init -upgrade
terraform plan -out=p.tfplan && terraform show -json p.tfplan
Defensive patterns

Strategy: validation

Validate before calling

// Verify every resource change has a schema before marshaling, so a
// missing provider is reported as an init problem, not a render crash.
for _, rc := range plan.Changes.Resources {
    sch := schemas.ResourceTypeConfig(
        rc.ProviderAddr.Provider,
        rc.Addr.Resource.Resource.Mode,
        rc.Addr.Resource.Resource.Type,
    )
    if sch.Body == nil {
        return fmt.Errorf("no schema for %s (provider %s); run terraform init",
            rc.Addr, rc.ProviderAddr.Provider)
    }
}

Try / catch

out, err := jsonplan.Marshal(config, plan, sf, schemas)
if err != nil && strings.Contains(err.Error(), "no schema found") {
    // instruct user to terraform init / align provider versions
}
return err

Prevention

When it happens

Trigger: Reached during any resource-change marshaling (resource_changes 608, deferred 609, drift 606) when the provider for a planned/drifted resource did not supply a schema for that resource type. The schemas map is built from installed providers, so a missing or mismatched provider yields a nil Body.

Common situations: Provider plugin not installed (terraform init not run or failed); provider version downgrade where the resource type was removed or renamed; aliased/mis-sourced provider so the type lookup does not match; state referencing a resource whose provider was removed from config.

Related errors


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