{"record":{"id":"436082081e9e844f","repo":"quarkusio/quarkus","slug":"s-callback-may-accept-at-most-1-message-paramete","errorCode":null,"errorMessage":"@%s callback may accept at most 1 message parameter; found %s: %s","messagePattern":"@(.+?) callback may accept at most 1 message parameter; found (.+?): (.+?)","errorType":"validation","errorClass":"WebSocketException","httpStatus":null,"severity":"error","filePath":"extensions/websockets-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java","lineNumber":1908,"sourceCode":"    }\n\n    private static Callback findCallback(Target target, IndexView index, BeanInfo bean, ClassInfo beanClass,\n            DotName annotationName, CallbackArgumentsBuildItem callbackArguments,\n            TransformedAnnotationsBuildItem transformedAnnotations, String endpointPath,\n            Consumer<Callback> validator) {\n        List<AnnotationInstance> annotations = findCallbackAnnotations(index, beanClass, annotationName);\n        if (annotations.isEmpty()) {\n            return null;\n        } else if (annotations.size() == 1) {\n            AnnotationInstance annotation = annotations.get(0);\n            MethodInfo method = annotation.target().asMethod();\n            Callback callback = new Callback(target, annotation, bean, method,\n                    executionModel(method, transformedAnnotations), callbackArguments, transformedAnnotations,\n                    endpointPath, index);\n            long messageArguments = callback.arguments.stream().filter(ca -> ca instanceof MessageCallbackArgument).count();\n            if (callback.acceptsMessage()) {\n                if (messageArguments > 1) {\n                    throw new WebSocketException(\n                            String.format(\"@%s callback may accept at most 1 message parameter; found %s: %s\",\n                                    DotNames.simpleName(callback.annotation.name()),\n                                    messageArguments,\n                                    callback.asString()));\n                }\n            } else {\n                if (messageArguments != 0) {\n                    throw new WebSocketException(\n                            String.format(\"@%s callback must not accept a message parameter; found %s: %s\",\n                                    DotNames.simpleName(callback.annotation.name()),\n                                    messageArguments,\n                                    callback.asString()));\n                }\n            }\n            if (target == Target.CLIENT && callback.broadcast()) {\n                throw new WebSocketClientException(\n                        String.format(\"@%s callback declared on a client endpoint must not broadcast messages: %s\",\n                                DotNames.simpleName(callback.annotation.name()),","sourceCodeStart":1890,"sourceCodeEnd":1926,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/websockets-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java#L1890-L1926","documentation":"Message-handling callbacks (e.g. @OnTextMessage, @OnBinaryMessage) may accept at most one message parameter. When the callback accepts messages (acceptsMessage()) but more than one parameter qualifies as a message argument, the build fails with the annotation name, count, and signature.","triggerScenarios":"An @OnTextMessage or @OnBinaryMessage method declaring two or more message-typed parameters (e.g. two String parameters, or String plus a custom DTO).","commonSituations":"Developer expects a message plus metadata as a second message parameter; copy-paste duplicating a parameter; misunderstanding which parameters count as message arguments.","solutions":["Keep exactly one message parameter; move secondary data into method context types (WebSocketConnection, @PathParam, HttpHeaders)","Wrap related fields into a single DTO and use one parameter (optionally with custom deserialization)","Remove the redundant parameter"],"exampleFix":"// before\n@OnTextMessage\nvoid onMessage(String payload, String extra) {}\n\n// after\nclass Msg { String payload; String extra; }\n@OnTextMessage\nvoid onMessage(Msg msg) {}\n","handlingStrategy":"validation","validationCode":"// Message callbacks may have at most one message parameter\n@OnTextMessage void onMessage(String msg) {} // single message slot","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Design one DTO per message type instead of multiple parameters","Use WebSocketConnection/@PathParam/HttpHeaders for non-message data","Review handler signatures after refactors"],"tags":["quarkus","websockets-next","build-time-validation","callback-signature"],"backgroundTag":"callback-parameter-type-mismatch","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"}