{"record":{"id":"d88e29ec154c7e3d","repo":"hashicorp/terraform","slug":"resource-identity-schema-version-d-for-s-in-stat","errorCode":null,"errorMessage":"resource identity schema version %d for %s in state does not match version %d from the provider","messagePattern":"resource identity schema version (.+?) for (.+?) in state does not match version (.+?) from the provider","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonstate/state.go","lineNumber":433,"sourceCode":"\t\t\t\tresAddr.Type,\n\t\t\t)\n\n\t\t\t// It is possible that the only instance is deposed\n\t\t\tif ri.Current != nil {\n\t\t\t\tif schema.Version != int64(ri.Current.SchemaVersion) {\n\t\t\t\t\treturn nil, fmt.Errorf(\"schema version %d for %s in state does not match version %d from the provider\", ri.Current.SchemaVersion, resAddr, schema.Version)\n\t\t\t\t}\n\n\t\t\t\tcurrent.SchemaVersion = ri.Current.SchemaVersion\n\n\t\t\t\tif schema.Body == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"no schema found for %s (in provider %s)\", resAddr.String(), r.ProviderConfig.Provider)\n\t\t\t\t}\n\n\t\t\t\t// Check if we have an identity in the state\n\t\t\t\tif ri.Current.IdentityJSON != nil {\n\t\t\t\t\tif schema.IdentityVersion != int64(ri.Current.IdentitySchemaVersion) {\n\t\t\t\t\t\treturn 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)\n\t\t\t\t\t}\n\n\t\t\t\t\tif schema.Identity == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"no resource identity schema found for %s (in provider %s)\", resAddr.String(), r.ProviderConfig.Provider)\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent.IdentitySchemaVersion = &ri.Current.IdentitySchemaVersion\n\t\t\t\t}\n\n\t\t\t\triObj, err := ri.Current.Decode(schema)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tvar value cty.Value\n\t\t\t\tvar sensitivePaths []cty.Path\n\t\t\t\tvalue, current.AttributeValues, sensitivePaths, err = marshalAttributeValues(riObj.Value)\n\t\t\t\tif err != nil {","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonstate/state.go#L415-L451","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before JSON state rendering, verify identity schema versions match the provider.\nfor _, r := range state.Resources {\n    if r.Current == nil || r.Current.IdentityJSON == nil { continue }\n    s := schemas.ResourceTypeConfig(r.ProviderConfig.Provider, r.Addr.Mode, r.Addr.Type)\n    if int64(r.Current.IdentitySchemaVersion) != s.IdentityVersion {\n        return fmt.Errorf(\"identity schema drift for %s: state=%d provider=%d\", r.Addr, r.Current.IdentitySchemaVersion, s.IdentityVersion)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := jsonstate.MarshalState(state, schemas); err != nil {\n    // Identity schema mismatch: re-apply with the current provider to migrate identity data.\n    return err\n}","preventionTips":["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."],"tags":["terraform","jsonstate","identity-schema","schema-version","version-mismatch"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}