{"record":{"id":"0aa69c11f214c6a0","repo":"quarkusio/quarkus","slug":"setting-both-withformread-and-prematching-to","errorCode":null,"errorMessage":"Setting both '@WithFormRead' and 'preMatching' to 'true' on '@ServerRequestFilter' is invalid. Offending method is '${methodInfo.name()}' of class '${methodInfo.declaringClass().name()}'","messagePattern":"Setting both '@WithFormRead' and 'preMatching' to 'true' on '@ServerRequestFilter' is invalid\\. Offending method is '(.+?)' of class '(.+?)'","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/FilterGeneration.java","lineNumber":68,"sourceCode":"                preMatching = preMatchingValue.asBoolean();\n            }\n            AnnotationValue nonBlockingRequiredValue = instance.value(\"nonBlocking\");\n            if (nonBlockingRequiredValue != null) {\n                nonBlockingRequired = nonBlockingRequiredValue.asBoolean();\n            }\n            AnnotationValue readBodyValue = instance.value(\"readBody\");\n            if (readBodyValue != null) {\n                readBody = readBodyValue.asBoolean();\n            }\n\n            if (preMatching) {\n                if (readBody) {\n                    throw new IllegalStateException(\n                            \"Setting both 'readBody' and 'preMatching' to 'true' on '@ServerRequestFilter' is invalid. Offending method is '\"\n                                    + methodInfo.name() + \"' of class '\" + methodInfo.declaringClass().name() + \"'\");\n                }\n                if (withFormRead) {\n                    throw new IllegalStateException(\n                            \"Setting both '@WithFormRead' and 'preMatching' to 'true' on '@ServerRequestFilter' is invalid. Offending method is '\"\n                                    + methodInfo.name() + \"' of class '\" + methodInfo.declaringClass().name() + \"'\");\n                }\n            }\n\n            List<AnnotationInstance> annotations = methodInfo.annotations();\n            for (AnnotationInstance annotation : annotations) {\n                if (SERVER_REQUEST_FILTER.equals(annotation.name())) {\n                    continue;\n                }\n                DotName annotationDotName = annotation.name();\n                ClassInfo annotationClassInfo = index.getClassByName(annotationDotName);\n                if (annotationClassInfo == null) {\n                    continue;\n                }\n                if ((annotationClassInfo.declaredAnnotation(ResteasyReactiveDotNames.NAME_BINDING) != null)) {\n                    nameBindingNames.add(annotationDotName.toString());\n                }","sourceCodeStart":50,"sourceCodeEnd":86,"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/FilterGeneration.java#L50-L86","documentation":"@WithFormRead forces the filter to run after form parameters are read, which requires the request to have been matched; a pre-matching filter runs before matching. Combining @WithFormRead with preMatching = true on @ServerRequestFilter is contradictory and rejected at build time by FilterGeneration.","triggerScenarios":"Declaring `@ServerRequestFilter(preMatching = true)` on a method also annotated with `@WithFormRead` and building the application.","commonSituations":"Needing form parameters (application/x-www-form-urlencoded) inside a pre-match authorization filter; adding @WithFormRead via copy-paste from another filter.","solutions":["Remove @WithFormRead if the pre-matching filter does not need form parameters.","Remove `preMatching = true` so the filter runs post-match with form data available.","Split into two filters: a pre-matching check and a post-match form-reading filter."],"exampleFix":"// before\n@WithFormRead\n@ServerRequestFilter(preMatching = true)\npublic void filter(ContainerRequestContext ctx) { ... }\n// after\n@WithFormRead\n@ServerRequestFilter\npublic void filter(ContainerRequestContext ctx) { /* form data accessible */ }","handlingStrategy":"validation","validationCode":"// @WithFormRead + preMatching = true is invalid; enforce at review/test time:\nWithFormRead wf = filterMethod.getAnnotation(WithFormRead.class);\nServerRequestFilter f = filterMethod.getAnnotation(ServerRequestFilter.class);\nif (wf != null && f != null && f.preMatching()) {\n    throw new IllegalStateException(\n        \"@WithFormRead cannot be combined with preMatching on \" + filterMethod);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Form parameter access requires a post-match filter; never annotate pre-matching filters with @WithFormRead.","Split into a pre-matching filter and a post-match form-reading filter.","Avoid copy-pasting @WithFormRead between filters.","Verify annotation combinations in a unit test using reflection."],"tags":["quarkus","resteasy-reactive","build-time","serverrequestfilter","configuration"],"backgroundTag":"conflicting-filter-options","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"}