{"record":{"id":"6868b17b615c02fa","repo":"apache/shenyu","slug":"constraint-violation-messages-joined-by-comma","errorCode":null,"errorMessage":"<constraint violation messages joined by comma>","messagePattern":"<constraint violation messages joined by comma>","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java","lineNumber":288,"sourceCode":"\n        // convert list to array\n        Class<?>[] classGroups = new Class<?>[groups.size()];\n        classGroups = groups.toArray(classGroups);\n\n        Object parameterBean = getMethodParameterBean(clazz, method, arguments);\n        if (Objects.nonNull(parameterBean)) {\n            violations.addAll(validator.validate(parameterBean, classGroups));\n        }\n\n        for (Object arg : arguments) {\n            validate(violations, arg, classGroups);\n        }\n\n        if (!violations.isEmpty()) {\n            LOG.error(\"Failed to validate service: {}, method: {}, cause: {}\", clazz.getName(), methodName, violations);\n            StringBuilder validateError = new StringBuilder();\n            violations.forEach(each -> validateError.append(each.getMessage()).append(\",\"));\n            throw new ValidationException(validateError.substring(0, validateError.length() - 1));\n        }\n    }\n\n    private void validate(final Set<ConstraintViolation<?>> violations, final Object arg, final Class<?>... groups) {\n        if (Objects.nonNull(arg) && !ReflectUtils.isPrimitives(arg.getClass())) {\n            if (arg instanceof Object[]) {\n                for (Object item : (Object[]) arg) {\n                    validate(violations, item, groups);\n                }\n            } else if (arg instanceof Collection) {\n                for (Object item : (Collection<?>) arg) {\n                    validate(violations, item, groups);\n                }\n            } else if (arg instanceof Map) {\n                for (Map.Entry<?, ?> entry : ((Map<?, ?>) arg).entrySet()) {\n                    validate(violations, entry.getKey(), groups);\n                    validate(violations, entry.getValue(), groups);\n                }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java#L270-L306","documentation":"ApacheDubboClientValidator runs Jakarta/Javax Bean Validation on a Dubbo service invocation's parameters. When any ConstraintViolation is found, it logs the failures and throws a Dubbo ValidationException whose message is all violation messages joined by commas. It is the client-side validation gate before a Dubbo call is dispatched.","triggerScenarios":"Invoking a Dubbo service method (via consumer or during testValidate) whose annotated arguments fail @NotNull/@Size/@Pattern etc. constraints; the collected violations are non-empty after validator.validate().","commonSituations":"Callers passing null required fields, strings exceeding @Size limits, malformed values against @Pattern/@Email constraints; schema drift between client DTO validation annotations and caller data.","solutions":["Read the joined messages to identify which parameters violated which constraints and fix the caller's input","Validate arguments with a Validator before making the Dubbo call","Relax/adjust the validation annotations on the service DTO if the constraints are wrong","Catch org.apache.dubbo.validation.ValidationException on the consumer side for graceful handling"],"exampleFix":"// before\nuserService.createUser(new UserDTO()); // missing name -> ValidationException\n// after\nSet<ConstraintViolation<UserDTO>> v = validator.validate(dto);\nif (!v.isEmpty()) { dto.setName(\"required-name\"); }\nuserService.createUser(dto);","handlingStrategy":"validation","validationCode":"Validator validator = Validation.buildDefaultValidatorFactory().getValidator();\nSet<ConstraintViolation<Object>> violations = validator.validate(dto);\nif (!violations.isEmpty()) {\n    throw new IllegalArgumentException(violations.stream()\n        .map(ConstraintViolation::getMessage).collect(Collectors.joining(\",\")));\n}","typeGuard":null,"tryCatchPattern":"try { dubboService.call(arg); }\ncatch (ValidationException e) {\n    log.warn(\"Invalid arguments: {}\", e.getMessage());\n}","preventionTips":["Pre-validate DTOs with a local Validator before remote calls","Keep validation annotations in sync with caller payloads","Log full violation details server-side for debugging"],"tags":["dubbo","bean-validation","input-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}