hashicorp/terraform · error
resource identity schema version %d for %s in state does not
Error message
resource identity schema version %d for %s in state does not match version %d from the provider
What it means
Thrown when a resource instance stores identity data in state but the identity schema version in state differs from the identity schema version the loaded provider reports. This is the identity-schema analogue of error 624: Terraform uses identity schema versions to upgrade identity blobs, and a mismatch prevents safe decoding.
Source
Thrown at internal/command/jsonstate/state.go:433
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
}
var value cty.Value
var sensitivePaths []cty.Path
value, current.AttributeValues, sensitivePaths, err = marshalAttributeValues(riObj.Value)
if err != nil {View on GitHub (pinned to c9def3e214)
Solutions
- Re-apply with the current provider so Terraform rewrites the resource identity in state under the new schema version.
- If the mismatch is from a downgrade, pin required_providers back to the version that wrote the identity data and re-init.
- Upgrade Terraform Core to a version that supports resource identity schema migrations.
- If identity data is stale and not needed, remove the resource from state (`terraform state rm`) and re-import.
Defensive patterns
Strategy: validation
Validate before calling
// Before JSON state rendering, verify identity schema versions match the provider.
for _, r := range state.Resources {
if r.Current == nil || r.Current.IdentityJSON == nil { continue }
s := schemas.ResourceTypeConfig(r.ProviderConfig.Provider, r.Addr.Mode, r.Addr.Type)
if int64(r.Current.IdentitySchemaVersion) != s.IdentityVersion {
return fmt.Errorf("identity schema drift for %s: state=%d provider=%d", r.Addr, r.Current.IdentitySchemaVersion, s.IdentityVersion)
}
} Try / catch
if _, err := jsonstate.MarshalState(state, schemas); err != nil {
// Identity schema mismatch: re-apply with the current provider to migrate identity data.
return err
} Prevention
- Re-apply after upgrading providers that change resource identity schemas.
- Keep Terraform Core and providers on versions with compatible identity schema support.
- Track provider changelogs for identity schema version bumps.
When it happens
Trigger: Occurs in jsonstate when ri.Current.IdentityJSON != nil and ri.Current.IdentitySchemaVersion != schema.IdentityVersion. Triggered by JSON state rendering after the provider changed its identity schema version (e.g. provider upgrade that restructured resource identity) without re-applying.
Common situations: Seen when a provider introduces or changes resource identity metadata (a newer Terraform/provider feature). The state was written with one identity schema version and the now-loaded provider expects another. Common after partial upgrades where state predates the new identity schema.
Related errors
- schema version %d for %s in state does not match version %d
- no resource identity schema found for %s (in provider %s)
- no schema found for %s (in provider %s)
- Remote workspace Terraform version %q does not match local T
- no schema found for %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/d88e29ec154c7e3d.
Report an issue: GitHub.