theonedev/onedev · error · IllegalArgumentException
The group must not be null.
Error message
The group must not be null.
What it means
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).
Source
Thrown at server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java:375
constraintValidatorManager,
constraintValidatorFactory,
validatorScopedContext,
TraversableResolvers.wrapWithCachingForSingleValidation( traversableResolver, validatorScopedContext.isTraversableResolverResultCacheEnabled() ),
constraintValidatorInitializationContext
);
}
private void sanityCheckPropertyPath(String propertyName) {
if ( propertyName == null || propertyName.length() == 0 ) {
throw LOG.getInvalidPropertyPathException();
}
}
private void sanityCheckGroups(Class<?>[] groups) {
Contracts.assertNotNull( groups, MESSAGES.groupMustNotBeNull() );
for ( Class<?> clazz : groups ) {
if ( clazz == null ) {
throw new IllegalArgumentException( MESSAGES.groupMustNotBeNull() );
}
}
}
private ValidationOrder determineGroupValidationOrder(Class<?>[] groups) {
Collection<Class<?>> resultGroups;
// if no groups is specified use the default
if ( groups.length == 0 ) {
resultGroups = DEFAULT_GROUPS;
}
else {
resultGroups = Arrays.asList( groups );
}
return validationOrderGenerator.getValidationOrder( resultGroups );
}
/**
* Validates the given object using the available context information.View on GitHub (pinned to d44925c47c)
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
Example fix
// before
validator.validate(bean, groups); // groups may be null
// after
Class<?>[] safeGroups = groups == null ? new Class<?>[]{javax.validation.groups.Default.class}
: java.util.Arrays.stream(groups).filter(java.util.Objects::nonNull).toArray(Class<?>[]::new);
validator.validate(bean, safeGroups); Defensive patterns
Strategy: validation
Validate before calling
if (groups == null) throw new IllegalArgumentException("groups required"); for (Class<?> g : groups) if (g == null) throw new IllegalArgumentException("null group element"); Type guard
boolean hasNoNullGroups(Class<?>[] gs) { return gs != null && java.util.Arrays.stream(gs).allMatch(java.util.Objects::nonNull); } Try / catch
try { validator.validate(bean, groups); } catch (IllegalArgumentException e) { log.warn("Invalid validation groups", e); validator.validate(bean); } Prevention
- 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
When it happens
Trigger: Calling validate/validateProperty/validateValue/validateParameters/validateReturnValue with groups == null, or an array like new Class<?>[]{Default.class, null} built dynamically.
Common situations: 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.
Related errors
- Invalid property path.
- Unable to reach the property to validate.
- Type not supported for unwrapping: {type}
- Error validating imported build spec (import project: %s, im
- ${violation.propertyPath}: ${violation.message}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/0dc1fc5142b267d2.
Report an issue: GitHub.