{"record":{"id":"dd98717a18688ecd","repo":"hashicorp/terraform","slug":"identity-schema-not-found-for-type-s","errorCode":null,"errorMessage":"identity schema not found for type %s","messagePattern":"identity schema not found for type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/grpcwrap/provider6.go","lineNumber":616,"sourceCode":"\t\tTargetTypeName:        request.TargetTypeName,\n\t\tSourceIdentity:        sourceIdentity,\n\t})\n\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, moveResp.Diagnostics)\n\tif moveResp.Diagnostics.HasErrors() {\n\t\treturn resp, nil\n\t}\n\n\ttargetSchema := p.schema.ResourceTypes[request.TargetTypeName]\n\ttargetType := targetSchema.Body.ImpliedType()\n\ttargetState, err := encodeDynamicValue6(moveResp.TargetState, targetType)\n\tif err != nil {\n\t\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)\n\t\treturn resp, nil\n\t}\n\n\tif !moveResp.TargetIdentity.IsNull() {\n\t\tif targetSchema.Identity == nil {\n\t\t\treturn resp, fmt.Errorf(\"identity schema not found for type %s\", request.TargetTypeName)\n\t\t}\n\n\t\ttargetIdentity, err := encodeDynamicValue6(moveResp.TargetIdentity, targetSchema.Identity.ImpliedType())\n\t\tif err != nil {\n\t\t\tresp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)\n\t\t\treturn resp, nil\n\t\t}\n\n\t\tresp.TargetIdentity = &tfplugin6.ResourceIdentityData{\n\t\t\tIdentityData: targetIdentity,\n\t\t}\n\t}\n\n\tresp.TargetState = targetState\n\tresp.TargetPrivate = moveResp.TargetPrivate\n\treturn resp, nil\n}\n","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/grpcwrap/provider6.go#L598-L634","documentation":"Returned inside the gRPC v6 provider wrapper (internal/grpcwrap/provider6.go:616, in MoveResourceState) when MoveResourceState's response carries a non-null TargetIdentity but the target resource type's schema in p.schema.ResourceTypes has a nil Identity block. The wrapper needs resSchema.Identity.ImpliedType() to encode the identity value, so a missing identity schema makes encoding impossible. The same literal appears at several other RPC handlers (ReadResource:302/334, PlanResourceChange:382/420, ApplyResourceChange:470/504, ImportResourceState:528/559) but index 944 pins line 616.","triggerScenarios":"A provider returns a populated identity (moveResp.TargetIdentity is not null) for a resource type whose schema declares no ResourceIdentity block; specifically during terraform state move/import where the wrapper tries to encode the returned identity. Caused by a provider bug or a schema/identity mismatch across provider versions.","commonSituations":"Upgrading a provider that started emitting identities to a Terraform core version that recorded a schema without the Identity block; a provider's GetProviderSchema reporting Identity for some types but not the type being moved; test harnesses wrapping a mock provider that returns identity without declaring it.","solutions":["Ensure the target resource type's schema (GetProviderSchema) declares an Identity block whenever the provider may return identity data for it.","Align the Terraform core version with the provider version so both understand resource identities.","If authoring a test provider behind grpcwrap.Provider6, populate provider6.identitySchemas/schema consistently in the providers.Interface implementation.","Report to the provider if the schema genuinely omits Identity yet the provider emits one (provider-side bug)."],"exampleFix":"// before (provider schema omits Identity but MoveResourceState returns identity)\nschema.ResourceTypes[\"aws_instance\"].Identity = nil\nmoveResp.TargetIdentity = cty.ObjectVal(...)  // -> identity schema not found for type aws_instance\n\n// after\nschema.ResourceTypes[\"aws_instance\"].Identity = providers.ResourceIdentitySchema{ /* fields */ }","handlingStrategy":"validation","validationCode":"// When wrapping a provider, assert schema/identity consistency up front:\nfunc validateIdentitySchemas(s providers.GetProviderSchemaResponse) error {\n    for typ, rs := range s.ResourceTypes {\n        _ = typ; _ = rs.Identity // document the contract\n    }\n    return nil\n}","typeGuard":"func typeHasIdentitySchema(s providers.GetProviderSchemaResponse, typ string) bool {\n    rs, ok := s.ResourceTypes[typ]\n    return ok && rs.Identity != nil\n}","tryCatchPattern":"// On the gRPC server side the error is terminal; clients should guard before sending identity:\nif !typeHasIdentitySchema(schema, req.TypeName) {\n    req.TargetIdentity = cty.NullVal(cty.DynamicPseudoType)\n}","preventionTips":["Keep GetProviderSchema and identity emission consistent in the provider.","Pin provider/core versions so both understand resource identity.","In test providers, populate schema.Identity whenever the provider may return identity.","Regression-test that every type emitting identity declares an Identity block."],"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"}