{"record":{"id":"e294f9415e641b46","repo":"hashicorp/terraform","slug":"no-schema-found-for-s-in-provider-s-e294f9","errorCode":null,"errorMessage":"no schema found for %s (in provider %s)","messagePattern":"no schema found for (.+?) \\(in provider (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonstate/state.go","lineNumber":427,"sourceCode":"\t\t\t\t)\n\t\t\t}\n\n\t\t\tschema := schemas.ResourceTypeConfig(\n\t\t\t\tr.ProviderConfig.Provider,\n\t\t\t\tresAddr.Mode,\n\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","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonstate/state.go#L409-L445","documentation":"Thrown by jsonstate after the schema-version check passes but schema.Body is still nil. schemas.ResourceTypeConfig returned a version number for the resource type yet no actual schema body, so the decoder cannot proceed. The message includes the provider address to disambiguate which provider is missing the definition.","triggerScenarios":"The provider exposes a version entry for the type but no schema (partial/corrupt schema load); the resource type was removed in the configured provider version but a version record lingers; stale provider schema cache from a previous, broken init.","commonSituations":"Provider major version removed/renamed the resource type while it remains in state; provider plugin crashed mid-schema and cached an incomplete schema; switching provider source (e.g. hashicorp/aws vs a fork) whose type catalogs differ.","solutions":["Run `terraform init -upgrade` to rebuild the provider schema cache from scratch.","Pin a provider version that still defines the resource type, or remove the obsolete resource from state with `terraform state rm`.","Inspect provider output/logs for schema retrieval errors.","If migrating providers, use `terraform state replace-provider` to remap the resource to a provider that defines it."],"exampleFix":"# obsolete resource left in state after provider upgrade\nterraform state rm azurerm_old_resource.x\n# or remap to a provider that still defines it\nterraform state replace-provider registry.terraform.io/hashicorp/azurerm registry.terraform.io/hashicorp/azurerm","handlingStrategy":"validation","validationCode":"schema := schemas.ResourceTypeConfig(r.ProviderConfig.Provider, resAddr.Mode, resAddr.Type)\nif schema.Body == nil {\n    return fmt.Errorf(\"provider %s exposes version %d for %s but no schema body; run 'terraform init -upgrade'\", r.ProviderConfig.Provider, schema.Version, resAddr)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `terraform init -upgrade` after switching provider source or version to rebuild the schema cache.","Remove obsolete resources from state with `terraform state rm` after a provider major-version change.","Use `terraform state replace-provider` when migrating between providers that define the same type."],"tags":["terraform","json-state","schema","provider","stale-cache"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}