{"record":{"id":"3b415aaeda5c8449","repo":"quarkusio/quarkus","slug":"the-combination-of-annotationname-and-serv","errorCode":null,"errorMessage":"The combination of '@${annotationName}' and '@ServerRequestFilter' or '@ServerResponseFilter' is not allowed. Offending method is '${methodName}' of class '${className}'","messagePattern":"The combination of '@(.+?)' and '@ServerRequestFilter' or '@ServerResponseFilter' is not allowed\\. Offending method is '(.+?)' of class '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java","lineNumber":437,"sourceCode":"                indexer.add(filter.getClassName());\n            }\n            for (CustomContainerResponseFilterBuildItem filter : customContainerResponseFilters) {\n                indexer.add(filter.getClassName());\n            }\n            for (CustomExceptionMapperBuildItem mapper : customExceptionMappers) {\n                indexer.add(mapper.getClassName());\n            }\n            LazyIndexer.Result result = indexer.complete();\n            index = CompositeIndex.create(index, result.index());\n        }\n\n        List<FilterGeneration.GeneratedFilter> generatedFilters = FilterGeneration.generate(index,\n                Set.of(HTTP_SERVER_REQUEST, HTTP_SERVER_RESPONSE, ROUTING_CONTEXT), Set.of(Unremovable.class.getName()),\n                (methodInfo -> {\n                    List<AnnotationInstance> methodAnnotations = methodInfo.annotations();\n                    for (AnnotationInstance methodAnnotation : methodAnnotations) {\n                        if (CONDITIONAL_BEAN_ANNOTATIONS.contains(methodAnnotation.name())) {\n                            throw new RuntimeException(\"The combination of '@\" + methodAnnotation.name().withoutPackagePrefix()\n                                    + \"' and '@ServerRequestFilter' or '@ServerResponseFilter' is not allowed. Offending method is '\"\n                                    + methodInfo.name() + \"' of class '\" + methodInfo.declaringClass().name() + \"'\");\n                        }\n                    }\n\n                    List<AnnotationInstance> classAnnotations = methodInfo.declaringClass().declaredAnnotations();\n                    for (AnnotationInstance classAnnotation : classAnnotations) {\n                        if (CONDITIONAL_BEAN_ANNOTATIONS.contains(classAnnotation.name())) {\n                            return true;\n                        }\n                    }\n                    return false;\n                }));\n        for (var generated : generatedFilters) {\n            for (var i : generated.getGeneratedClasses()) {\n                generatedBean.produce(new GeneratedBeanBuildItem(i.getName(), i.getData()));\n            }\n            if (generated.isRequestFilter()) {","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java#L419-L455","documentation":"Quarkus REST rejects combining bean-conditional annotations (@IfBuildProfile, @IfBuildProperty, @Startup, etc. — CONDITIONAL_BEAN_ANNOTATIONS) with @ServerRequestFilter or @ServerResponseFilter. During deployment, custom-annotated filter methods are generated into beans, and the conditional annotation would be lost or ambiguous, so the build fails fast.","triggerScenarios":"Declaring a method annotated with @ServerRequestFilter or @ServerResponseFilter that also carries one of the conditional bean annotations (e.g. @io.quarkus.arc.profile.IfBuildProfile, @io.quarkus.arc.properties.IfBuildProperty) on the method itself.","commonSituations":"Trying to enable a filter only in a certain profile or property by annotating the filter method; migrating a CDI filter class to Quarkus REST's generated-filter mechanism while keeping profile annotations.","solutions":["Remove the conditional annotation from the filter method","Move the conditional annotation to the declaring class level (so the whole bean is conditional)","Implement the filter as a regular CDI bean with ContainerRequestFilter/ContainerResponseFilter and apply the conditional annotation there","Split the filter into per-profile classes each with its own @ServerRequestFilter implementation"],"exampleFix":"// before\n@IfBuildProfile(\"prod\")\n@ServerRequestFilter\npublic void filter(HttpServerRequest req) { ... }\n// after: annotate the class instead\n@IfBuildProfile(\"prod\")\npublic class ProdFilters {\n    @ServerRequestFilter\n    public void filter(HttpServerRequest req) { ... }\n}\n","handlingStrategy":"validation","validationCode":"// build-time check: no conditional annotations on filter methods\nfor (AnnotationInstance a : method.annotations()) {\n    if (CONDITIONAL_BEAN_ANNOTATIONS.contains(a.name())) {\n        throw new IllegalArgumentException(\"Remove \" + a + \" from @ServerRequestFilter method \" + method.name());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never put @IfBuildProfile/@IfBuildProperty/@Startup on @ServerRequestFilter/@ServerResponseFilter methods","Apply conditions at the class level or via plain CDI filters","Review filter classes after migrating from CDI filters"],"tags":["quarkus","resteasy-reactive","annotation-misuse","build-time","filters"],"backgroundTag":"incompatible-annotation-combination","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}