{"record":{"id":"aee1cefeb5a5f167","repo":"quarkusio/quarkus","slug":"clientannotation-may-not-be-declared-at-targe","errorCode":null,"errorMessage":"${clientAnnotation} may not be declared at ${target}","messagePattern":"(.+?) may not be declared at (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java","lineNumber":174,"sourceCode":"            String clientName;\n            AnnotationValue clientNameValue = clientAnnotation.value();\n            if (clientNameValue == null || clientNameValue.asString().equals(GrpcClient.ELEMENT_NAME)) {\n                // Determine the service name from the annotated element\n                if (clientAnnotation.target().kind() == Kind.FIELD) {\n                    clientName = clientAnnotation.target().asField().name();\n                } else if (clientAnnotation.target().kind() == Kind.METHOD_PARAMETER) {\n                    MethodParameterInfo param = clientAnnotation.target().asMethodParameter();\n                    clientName = param.method().parameterName(param.position());\n                    if (clientName == null) {\n                        throw new DeploymentException(\"Unable to determine the client name from the parameter at position \"\n                                + param.position()\n                                + \" in method \"\n                                + param.method().declaringClass().name() + \"#\" + param.method().name()\n                                + \"() - compile the class with debug info enabled (-g) or parameter names recorded (-parameters), or use GrpcClient#value() to specify the service name\");\n                    }\n                } else {\n                    // This should never happen because @GrpcClient has @Target({ FIELD, PARAMETER })\n                    throw new IllegalStateException(clientAnnotation + \" may not be declared at \" + clientAnnotation.target());\n                }\n            } else {\n                clientName = clientNameValue.asString();\n            }\n\n            if (clientName.trim().isEmpty()) {\n                throw new DeploymentException(\n                        \"Invalid @GrpcClient `\" + injectionPoint.getTargetInfo() + \"` - client name cannot be empty\");\n            }\n\n            GrpcClientBuildItem item;\n            if (items.containsKey(clientName)) {\n                item = items.get(clientName);\n            } else {\n                item = new GrpcClientBuildItem(clientName);\n                items.put(clientName, item);\n            }\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java#L156-L192","documentation":"@GrpcClient is only allowed on fields and method parameters (@Target({FIELD, PARAMETER})). If the annotation instance is found on any other target (class, method, etc.), the deployment throws this IllegalStateException. This is a defensive check that should be unreachable in normal Java code.","triggerScenarios":"An @GrpcClient annotation instance whose reflection target is neither a field nor a method parameter is processed during injection-point discovery — practically only via bytecode-generated/transformed classes or exotic annotation processing.","commonSituations":"Code-generation or bytecode tooling that misplaced the annotation; custom CDI extensions registering synthetic annotated members; manually built annotation instances in build steps.","solutions":["Move @GrpcClient onto a field or a method parameter","If generated by a tool, fix the generator to respect @GrpcClient's @Target","Ensure no custom annotation transformer re-targets @GrpcClient"],"exampleFix":"// before\n@GrpcClient(\"svc\")\npublic class MyService { ... }\n\n// after\npublic class MyService {\n    @Inject @GrpcClient(\"svc\") Greeter greeter;\n}","handlingStrategy":"validation","validationCode":"// only place @GrpcClient on fields or method parameters\n@Target({ElementType.FIELD, ElementType.PARAMETER}) // existing definition — respect it\nclass MyBean { @Inject @GrpcClient(\"svc\") Greeter greeter; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check @Target of an annotation before applying it","Never apply @GrpcClient at class or method level"],"tags":["grpc","cdi","annotation-misuse"],"backgroundTag":"invalid-annotation-target","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}