hashicorp/terraform · error

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

Error message

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

What it means

Thrown by the JSON state serializer when the provider schema lookup returns a nil Body for a resource type that exists in state. The provider is loaded but does not define a schema for that resource type, so the stored object cannot be decoded. Equivalent of error 622 but for state serialization.

Source

Thrown at internal/command/jsonstate/state.go:427

				)
			}

			schema := schemas.ResourceTypeConfig(
				r.ProviderConfig.Provider,
				resAddr.Mode,
				resAddr.Type,
			)

			// It is possible that the only instance is deposed
			if ri.Current != nil {
				if schema.Version != int64(ri.Current.SchemaVersion) {
					return nil, fmt.Errorf("schema version %d for %s in state does not match version %d from the provider", ri.Current.SchemaVersion, resAddr, schema.Version)
				}

				current.SchemaVersion = ri.Current.SchemaVersion

				if schema.Body == nil {
					return nil, fmt.Errorf("no schema found for %s (in provider %s)", resAddr.String(), r.ProviderConfig.Provider)
				}

				// Check if we have an identity in the state
				if ri.Current.IdentityJSON != nil {
					if schema.IdentityVersion != int64(ri.Current.IdentitySchemaVersion) {
						return nil, fmt.Errorf("resource identity schema version %d for %s in state does not match version %d from the provider", ri.Current.IdentitySchemaVersion, resAddr, schema.IdentityVersion)
					}

					if schema.Identity == nil {
						return nil, fmt.Errorf("no resource identity schema found for %s (in provider %s)", resAddr.String(), r.ProviderConfig.Provider)
					}

					current.IdentitySchemaVersion = &ri.Current.IdentitySchemaVersion
				}

				riObj, err := ri.Current.Decode(schema)
				if err != nil {
					return nil, err

View on GitHub (pinned to c9def3e214)

Solutions

  1. Check the provider's changelog for the resource type's removal/rename and use the version that still defines it.
  2. Run `terraform providers schema -json` to confirm which provider/version defines the type.
  3. Pin required_providers to a version that includes the resource type and run `terraform init`.
  4. If the resource is gone for good, `terraform state rm` it (and re-create/import with the replacement type if one exists).

Example fix

// before: provider version that removed the resource
terraform {
  required_providers {
    kubernetes = { source = "hashicorp/kubernetes", version = "~> 2.20" }
  }
}
// after: pin to a version that still defines the resource type in state
terraform {
  required_providers {
    kubernetes = { source = "hashicorp/kubernetes", version = "= 2.10.0" }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// Before serializing state as JSON, ensure each resource type is defined by its provider.
for _, r := range state.Resources {
    s := schemas.ResourceTypeConfig(r.ProviderConfig.Provider, r.Addr.Mode, r.Addr.Type)
    if r.Current != nil && s.Body == nil {
        return fmt.Errorf("provider %s has no schema for %s — pin a provider version that defines it", r.ProviderConfig.Provider, r.Addr.Type)
    }
}

Try / catch

if _, err := jsonstate.MarshalState(state, schemas); err != nil {
    // Missing schema: instruct user to install a provider version that defines the type.
    return err
}

Prevention

When it happens

Trigger: Occurs in jsonstate when schema.Body == nil after ResourceTypeConfig lookup for a resource type present in ri.Current. Triggered by any JSON state rendering when the loaded provider no longer ships the resource type stored in state.

Common situations: The resource type was removed or renamed in the installed provider version (e.g. provider dropped a deprecated resource). Also happens with aliased/misconfigured providers or after a `terraform state replace-provider` to a provider that lacks the type.

Related errors


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