{"record":{"id":"0dc1fc5142b267d2","repo":"theonedev/onedev","slug":"the-group-must-not-be-null","errorCode":null,"errorMessage":"The group must not be null.","messagePattern":"The group must not be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java","lineNumber":375,"sourceCode":"\t\t\t\tconstraintValidatorManager,\n\t\t\t\tconstraintValidatorFactory,\n\t\t\t\tvalidatorScopedContext,\n\t\t\t\tTraversableResolvers.wrapWithCachingForSingleValidation( traversableResolver, validatorScopedContext.isTraversableResolverResultCacheEnabled() ),\n\t\t\t\tconstraintValidatorInitializationContext\n\t\t);\n\t}\n\n\tprivate void sanityCheckPropertyPath(String propertyName) {\n\t\tif ( propertyName == null || propertyName.length() == 0 ) {\n\t\t\tthrow LOG.getInvalidPropertyPathException();\n\t\t}\n\t}\n\n\tprivate void sanityCheckGroups(Class<?>[] groups) {\n\t\tContracts.assertNotNull( groups, MESSAGES.groupMustNotBeNull() );\n\t\tfor ( Class<?> clazz : groups ) {\n\t\t\tif ( clazz == null ) {\n\t\t\t\tthrow new IllegalArgumentException( MESSAGES.groupMustNotBeNull() );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ValidationOrder determineGroupValidationOrder(Class<?>[] groups) {\n\t\tCollection<Class<?>> resultGroups;\n\t\t// if no groups is specified use the default\n\t\tif ( groups.length == 0 ) {\n\t\t\tresultGroups = DEFAULT_GROUPS;\n\t\t}\n\t\telse {\n\t\t\tresultGroups = Arrays.asList( groups );\n\t\t}\n\t\treturn validationOrderGenerator.getValidationOrder( resultGroups );\n\t}\n\n\t/**\n\t * Validates the given object using the available context information.","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java#L357-L393","documentation":"ValidatorImpl.sanityCheckGroups enforces the Bean Validation contract that the groups array must not be null and must not contain null elements. Passing a null groups array or a null group class throws \"The group must not be null.\" (IllegalArgumentException).","triggerScenarios":"Calling validate/validateProperty/validateValue/validateParameters/validateReturnValue with groups == null, or an array like new Class<?>[]{Default.class, null} built dynamically.","commonSituations":"Building group arrays from configuration or annotations where some entries resolve to null; reflection code appending a null class; varargs calls with a null Class value.","solutions":["Pass an empty array or Default.class instead of null groups","Filter null entries out of dynamically built group arrays","Assert group classes are non-null before invoking the validator"],"exampleFix":"// before\nvalidator.validate(bean, groups); // groups may be null\n// after\nClass<?>[] safeGroups = groups == null ? new Class<?>[]{javax.validation.groups.Default.class}\n        : java.util.Arrays.stream(groups).filter(java.util.Objects::nonNull).toArray(Class<?>[]::new);\nvalidator.validate(bean, safeGroups);","handlingStrategy":"validation","validationCode":"if (groups == null) throw new IllegalArgumentException(\"groups required\"); for (Class<?> g : groups) if (g == null) throw new IllegalArgumentException(\"null group element\");","typeGuard":"boolean hasNoNullGroups(Class<?>[] gs) { return gs != null && java.util.Arrays.stream(gs).allMatch(java.util.Objects::nonNull); }","tryCatchPattern":"try { validator.validate(bean, groups); } catch (IllegalArgumentException e) { log.warn(\"Invalid validation groups\", e); validator.validate(bean); }","preventionTips":["Never build group arrays with null entries; filter with Objects::nonNull","Pass Default.class or an empty array rather than null","Sanitize group arrays derived from reflection/config"],"tags":["hibernate-validator","bean-validation","groups","illegal-argument"],"backgroundTag":"null-argument","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}