{"record":{"id":"96d85c80f42f8c28","repo":"quarkusio/quarkus","slug":"method-targetmethod-name-of-class-targetm-96d85c","errorCode":null,"errorMessage":"Method '${targetMethod.name()} of class '${targetMethod.declaringClass().name()}' cannot be used as a request filter as it does not declare 'void', Response, RestResponse, Optional<Response>, Optional<RestResponse>, 'Uni<Void>', 'Uni<RestResponse>' or 'Uni<Response>' as its return type","messagePattern":"Method '(.+?) of class '(.+?)' cannot be used as a request filter as it does not declare 'void', Response, RestResponse, Optional<Response>, Optional<RestResponse>, 'Uni<Void>', 'Uni<RestResponse>' or 'Uni<Response>' as its return type","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java","lineNumber":741,"sourceCode":"                    return ReturnType.UNI_VOID;\n                } else if (parameterizedType.arguments().get(0).name().equals(RESPONSE)) {\n                    return ReturnType.UNI_RESPONSE;\n                } else if (parameterizedType.arguments().get(0).name().equals(REST_RESPONSE)) {\n                    return ReturnType.UNI_REST_RESPONSE;\n                }\n            } else if (parameterizedType.name().equals(OPTIONAL) && (parameterizedType.arguments().size() == 1)) {\n                if (parameterizedType.arguments().get(0).name().equals(RESPONSE)) {\n                    return ReturnType.OPTIONAL_RESPONSE;\n                } else if (parameterizedType.arguments().get(0).name().equals(REST_RESPONSE)) {\n                    return ReturnType.OPTIONAL_REST_RESPONSE;\n                }\n            } else if (parameterizedType.name().equals(REST_RESPONSE)) {\n                return ReturnType.REST_RESPONSE;\n            }\n        } else if (targetMethod.returnType().name().equals(RESPONSE)) {\n            return ReturnType.RESPONSE;\n        }\n        throw new RuntimeException(\"Method '\" + targetMethod.name() + \" of class '\" + targetMethod.declaringClass().name()\n                + \"' cannot be used as a request filter as it does not declare 'void', Response, RestResponse, Optional<Response>, Optional<RestResponse>, 'Uni<Void>', 'Uni<RestResponse>' or 'Uni<Response>' as its return type\");\n    }\n\n    private ReturnType determineResponseFilterReturnType(MethodInfo targetMethod) {\n        if (targetMethod.returnType().kind() == Type.Kind.VOID) {\n            return ReturnType.VOID;\n        } else if (targetMethod.returnType().kind() == Type.Kind.PARAMETERIZED_TYPE) {\n            ParameterizedType parameterizedType = targetMethod.returnType().asParameterizedType();\n            if (parameterizedType.name().equals(UNI) && (parameterizedType.arguments().size() == 1)) {\n                if (parameterizedType.arguments().get(0).name().equals(VOID)) {\n                    return ReturnType.UNI_VOID;\n                }\n            }\n        }\n        throw new RuntimeException(\"Method '\" + targetMethod.name() + \" of class '\" + targetMethod.declaringClass().name()\n                + \"' cannot be used as a response filter as it does not declare 'void' or 'Uni<Void>' as its return type\");\n    }\n","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java#L723-L759","documentation":"A @ServerRequestFilter method must return one of: void, Response, RestResponse, Optional<Response>, Optional<RestResponse>, Uni<Void>, Uni<Response> or Uni<RestResponse>. The generated filter machinery relies on the return value to decide whether to abort the request chain. determineRequestFilterReturnType throws if the return type maps to none of these.","triggerScenarios":"Annotating a method with @ServerRequestFilter whose return type is anything else (String, boolean, Uni<String>, CompletionStage<Response>, custom POJO) and building the application.","commonSituations":"Returning boolean intending 'continue or abort'; returning Uni<String> instead of Uni<Response>; using CompletionStage instead of the supported Uni type; accidentally importing a custom Response class instead of jakarta.ws.rs.core.Response.","solutions":["Return void if the filter never aborts the request.","Return Response (or Optional<Response>) to conditionally abort with a custom response.","For reactive filters use Uni<Void>, Uni<Response> or Uni<RestResponse>, not CompletionStage.","Remove the @ServerRequestFilter annotation if the method is not intended as a filter."],"exampleFix":"// before\n@ServerRequestFilter\npublic boolean check(ContainerRequestContext ctx) { return true; }\n// after\n@ServerRequestFilter\npublic void check(ContainerRequestContext ctx) { /* return Response to abort */ }","handlingStrategy":"validation","validationCode":"import java.lang.reflect.Method;\nimport java.util.Set;\n\nvoid validateRequestFilterReturnType(Method m) {\n    Class<?> rt = m.getReturnType();\n    boolean ok = rt == void.class\n        || rt.getName().equals(\"jakarta.ws.rs.core.Response\")\n        || rt == java.util.Optional.class\n        || rt.getName().equals(\"io.smallrye.mutiny.Uni\");\n    if (!ok) throw new IllegalStateException(\n        \"Unsupported @ServerRequestFilter return type: \" + rt.getName());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only documented return types: void, Response, RestResponse, Optional<Response/RestResponse>, Uni<Void/Response/RestResponse>.","Never return boolean or CompletionStage from filters.","Import jakarta.ws.rs.core.Response, not a same-named custom class.","Consult the @ServerRequestFilter Javadoc when unsure of the signature."],"tags":["quarkus","resteasy-reactive","build-time","filters","return-type"],"backgroundTag":"invalid-filter-signature","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"}