{"record":{"id":"a27451cacdd33f71","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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/grpcwrap/provider6.go","lineNumber":821,"sourceCode":"func (p *provider6) GetResourceIdentitySchemas(_ context.Context, req *tfplugin6.GetResourceIdentitySchemas_Request) (*tfplugin6.GetResourceIdentitySchemas_Response, error) {\n\tresp := &tfplugin6.GetResourceIdentitySchemas_Response{\n\t\tIdentitySchemas: map[string]*tfplugin6.ResourceIdentitySchema{},\n\t\tDiagnostics:     []*tfplugin6.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 *provider6) UpgradeResourceIdentity(_ context.Context, req *tfplugin6.UpgradeResourceIdentity_Request) (*tfplugin6.UpgradeResourceIdentity_Response, error) {\n\tresp := &tfplugin6.UpgradeResourceIdentity_Response{}\n\tresource, ok := p.identitySchemas.IdentityTypes[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.Body.ImpliedType()\n\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\n\tif upgradeResp.Diagnostics.HasErrors() {\n\t\treturn resp, nil\n\t}\n\n\tdv, err := encodeDynamicValue6(upgradeResp.UpgradedIdentity, ty)\n\tif err != nil {\n\t\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)\n\t\treturn resp, nil","sourceCodeStart":803,"sourceCodeEnd":839,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/grpcwrap/provider6.go#L803-L839","documentation":"Returned by UpgradeResourceIdentity (internal/grpcwrap/provider6.go:821) when req.TypeName is not present in p.identitySchemas.IdentityTypes (a map populated once from p.GetResourceIdentitySchemas() at provider6 construction). The handler needs the identity schema's ImpliedType to encode the upgraded identity, so a missing entry is fatal and returns (nil, error).","triggerScenarios":"Terraform core requests an UpgradeResourceIdentity RPC for a resource type the provider never registered in its GetResourceIdentitySchemas response; the map lookup p.identitySchemas.IdentityTypes[req.TypeName] returns ok==false.","commonSituations":"Provider version mismatch where the running provider binary lacks an identity schema for a type present in older state; a typo'd/case-mismatched type name in the request; state written by a newer provider read by an older core; provider forgetting to register identity schemas for types that have identities in state.","solutions":["Upgrade the provider so its GetResourceIdentitySchemas declares the requested type.","Verify the type name in the request matches exactly (case-sensitive) the provider's registered identity type names.","Re-run terraform init to install a provider version consistent with the state's identity schema versions.","If migrating, use moved blocks / remove state for the unregistered type rather than forcing identity upgrade."],"exampleFix":"// before\n// provider's GetResourceIdentitySchemas omits \"aws_instance\"\n// core sends UpgradeResourceIdentity{TypeName:\"aws_instance\"}\n// -> resource identity schema not found for type \"aws_instance\"\n\n// after\n// in the provider, register:\nresp.IdentityTypes[\"aws_instance\"] = &ResourceIdentitySchema{Version:1, Body:...}","handlingStrategy":"validation","validationCode":"// Before requesting UpgradeResourceIdentity, confirm registration:\nfunc identityTypeRegistered(s providers.GetResourceIdentitySchemasResponse, typ string) bool {\n    _, ok := s.IdentityTypes[typ]\n    return ok\n}","typeGuard":"func knownIdentityTypes(s providers.GetResourceIdentitySchemasResponse) []string {\n    out := make([]string, 0, len(s.IdentityTypes))\n    for k := range s.IdentityTypes { out = append(out, k) }\n    return out\n}","tryCatchPattern":"if _, err := server.UpgradeResourceIdentity(ctx, req); err != nil {\n    if strings.Contains(err.Error(), \"resource identity schema not found\") {\n        // skip identity upgrade for this type / upgrade provider\n    }\n}","preventionTips":["Ensure every type with state identity is registered in GetResourceIdentitySchemas.","Match request type names to registered names exactly (case-sensitive).","Re-run terraform init when changing provider versions that alter identity schemas.","Handle unregistered types gracefully (skip rather than abort)."],"tags":["grpc","provider","identity","schema","terraform-core"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}