{"record":{"id":"06900c8048afff18","repo":"quarkusio/quarkus","slug":"dynamic-parameter-constraint-violations-summary","errorCode":null,"errorMessage":"(dynamic: parameter constraint violations summary for the invoked method)","messagePattern":"\\(dynamic: parameter constraint violations summary for the invoked method\\)","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/interceptor/AbstractMethodValidationInterceptor.java","lineNumber":69,"sourceCode":"     * return value of the intercepted method.\n     *\n     * @param ctx The context of the intercepted method invocation.\n     *\n     * @return The result of the method invocation.\n     *\n     * @throws Exception Any exception caused by the intercepted method invocation.\n     *         A {@link ConstraintViolationException} in case at least one\n     *         constraint violation occurred either during parameter or\n     *         return value validation.\n     */\n    protected Object validateMethodInvocation(InvocationContext ctx) throws Exception {\n\n        ExecutableValidator executableValidator = validatorInstance.get().forExecutables();\n        Set<ConstraintViolation<Object>> violations = executableValidator.validateParameters(ctx.getTarget(),\n                ctx.getMethod(), ctx.getParameters());\n\n        if (!violations.isEmpty()) {\n            throw new ConstraintViolationException(getMessage(ctx.getMethod(), ctx.getParameters(), violations),\n                    violations);\n        }\n\n        Object result = ctx.proceed();\n\n        violations = executableValidator.validateReturnValue(ctx.getTarget(), ctx.getMethod(), result);\n\n        if (!violations.isEmpty()) {\n            throw new ConstraintViolationException(getMessage(ctx.getMethod(), ctx.getParameters(), violations),\n                    violations);\n        }\n\n        return result;\n    }\n\n    /**\n     * Validates the Bean Validation constraints specified at the parameters and/or\n     * return value of the intercepted constructor.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/interceptor/AbstractMethodValidationInterceptor.java#L51-L87","documentation":"This is a jakarta.validation.ConstraintViolationException thrown by Quarkus's Hibernate Validator method-validation interceptor before the intercepted method runs. ExecutableValidator.validateParameters found at least one Bean Validation constraint violation among the method's arguments, so the method body is never executed. The message is dynamically built as 'N constraint violation(s) occurred during method validation' and lists the method, argument values, and each violation.","triggerScenarios":"Calling a CDI bean method annotated for method validation (e.g. @ValidateOnExecution or automatic on REST/GraphQL endpoints) with arguments that violate @NotNull/@Size/@Min/@Pattern etc. declared on its parameters; the interceptor checks violations at AbstractMethodValidationInterceptor.java:68-71 and throws before ctx.proceed().","commonSituations":"Passing null to a @NotNull parameter; sending an oversized string to a @Size(max=...) parameter from a REST client; forgetting @Valid on a nested parameter bean so violations surface here instead of a nicer 400 response; calling internal beans directly in tests with invalid data.","solutions":["Inspect the ConstraintViolationException's getConstraintViolations() set to see exactly which parameter and constraint failed.","Fix the caller to pass arguments satisfying the declared constraints, or relax the constraint annotations if the rules are too strict.","For REST endpoints, map ConstraintViolationException to a 400 response via a dedicated ExceptionMapper (quarkus-hibernate-validator provides default handling) or ExceptionMapper<ConstraintViolationException>.","Add @Valid on cascading parameters so nested violations are reported with full paths."],"exampleFix":"// before\npublic void create(@NotNull @Size(min = 3) String name) { ... }\nservice.create(\"ab\"); // throws ConstraintViolationException\n\n// after\nservice.create(\"abc\"); // passes @Size(min=3)","handlingStrategy":"validation","validationCode":"Set<ConstraintViolation<Object>> violations = validator.forExecutables().validateParameters(target, method, args);\nif (!violations.isEmpty()) { /* fix input or surface a 400 */ }","typeGuard":"boolean isValidParams = validator.forExecutables().validateParameters(bean, method, args).isEmpty();","tryCatchPattern":"try { service.create(name); } catch (ConstraintViolationException e) { violations = e.getConstraintViolations(); // log/return 400 }","preventionTips":["Validate inputs at the API boundary before calling validated beans","Keep constraint annotations on parameters in sync with client contracts","Add tests that exercise boundary values for @Size/@Min/@Max parameters","Register an ExceptionMapper for ConstraintViolationException to return 400 with violation details"],"tags":["bean-validation","constraint-violation","method-validation","quarkus"],"backgroundTag":"constraint-violation-exception","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"}