{"record":{"id":"50fc52253fd0ce5a","repo":"hashicorp/terraform","slug":"resource-identity-schema-not-found-for-type-q","errorCode":null,"errorMessage":"resource identity schema not found for type %q","messagePattern":"resource identity schema not found for type %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/grpcwrap/provider.go","lineNumber":760,"sourceCode":"func (p *provider) GetResourceIdentitySchemas(_ context.Context, req *tfplugin5.GetResourceIdentitySchemas_Request) (*tfplugin5.GetResourceIdentitySchemas_Response, error) {\n\tresp := &tfplugin5.GetResourceIdentitySchemas_Response{\n\t\tIdentitySchemas: map[string]*tfplugin5.ResourceIdentitySchema{},\n\t\tDiagnostics:     []*tfplugin5.Diagnostic{},\n\t}\n\n\tfor name, schema := range p.identitySchemas.IdentityTypes {\n\t\tresp.IdentitySchemas[name] = convert.ResourceIdentitySchemaToProto(schema)\n\t}\n\n\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, p.identitySchemas.Diagnostics)\n\treturn resp, nil\n}\n\nfunc (p *provider) UpgradeResourceIdentity(_ context.Context, req *tfplugin5.UpgradeResourceIdentity_Request) (*tfplugin5.UpgradeResourceIdentity_Response, error) {\n\tresp := &tfplugin5.UpgradeResourceIdentity_Response{}\n\tresource, ok := p.schema.ResourceTypes[req.TypeName]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"resource identity schema not found for type %q\", req.TypeName)\n\t}\n\tty := resource.Identity.ImpliedType()\n\tupgradeResp := p.provider.UpgradeResourceIdentity(providers.UpgradeResourceIdentityRequest{\n\t\tTypeName:        req.TypeName,\n\t\tVersion:         req.Version,\n\t\tRawIdentityJSON: req.RawIdentity.Json,\n\t})\n\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, upgradeResp.Diagnostics)\n\tif upgradeResp.Diagnostics.HasErrors() {\n\t\treturn resp, nil\n\t}\n\n\tdv, err := encodeDynamicValue(upgradeResp.UpgradedIdentity, ty)\n\tif err != nil {\n\t\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)\n\t\treturn resp, nil\n\t}\n\tresp.UpgradedIdentity = &tfplugin5.ResourceIdentityData{","sourceCodeStart":742,"sourceCodeEnd":778,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/grpcwrap/provider.go#L742-L778","documentation":"Returned in UpgradeResourceIdentity when the requested resource type name is not present in p.schema.ResourceTypes. Distinct from the 'identity schema not found' family: here the entire resource type is unknown, so the wrapper cannot even reach resource.Identity.ImpliedType(). Returns nil response with a gRPC error. Uses %q (quoted) formatting, unlike the %s used by the identity-not-found errors. '%q' is the requested type name.","triggerScenarios":"UpgradeResourceIdentityRequest arrives with a TypeName that is absent from the provider's declared ResourceTypes map. The provider has no schema for that type at all, so identity upgrade is impossible.","commonSituations":"State file references a resource type the current provider build no longer registers; typo in the request type name; provider namespace/name change left stale state; partial provider upgrade where the type was renamed or removed; test fixture requesting a non-existent type.","solutions":["Run 'terraform providers schema' to list the resource types the active provider registers; the requested type must appear there.","If the type was renamed, use 'removed' block or 'moved' block to migrate state, or manually edit state to the new type name.","Upgrade or downgrade the provider to match the state's resource type names.","Confirm the provider in .terraform.lock.hcl is the build expected to register the type.","If authoring a provider, ensure GetProviderSchema registers every resource type that may appear in state."],"exampleFix":"// before: state references 'example_old_thing' but provider only registers 'example_thing'\n// after: rename in state\n$ terraform state replace-provider example.com/example/example_old_thing example.com/example/example_thing\n// or update provider to register the legacy alias type","handlingStrategy":"type-guard","validationCode":"// Caller-side: verify resource type exists before requesting identity upgrade.\nif _, ok := schemas.ResourceTypes[req.TypeName]; !ok {\n    return fmt.Errorf(\"type %q not registered; cannot upgrade identity\", req.TypeName)\n}","typeGuard":"func typeRegistered(schemas *schemas.Schemas, t string) bool {\n    _, ok := schemas.ResourceTypes[t]; return ok\n}","tryCatchPattern":"// Caller-side: rename state to current type name then retry.\nif err != nil && strings.Contains(err.Error(), \"resource identity schema not found for type\") {\n    if mapped := legacyTypeMap[req.TypeName]; mapped != \"\" {\n        req.TypeName = mapped\n        return retry()\n    }\n}","preventionTips":["Use 'moved'/'removed' blocks or state replace-provider to migrate renamed resource types.","Keep .terraform.lock.hcl pinned to a provider that registers all state types.","Run terraform providers schema and reconcile any missing types before operations."],"tags":["grpcwrap","identity","schema","upgrade","terraform","resource-type"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}