theonedev/onedev · error · ValidationException
Type not supported for unwrapping: {type}
Error message
Type not supported for unwrapping: {type} What it means
ValidatorImpl.unwrap(Class) per the Bean Validation spec returns the underlying provider-specific type when supported; ValidatorImpl only supports unwrapping to Validator (itself). Requesting any other type throws "Type not supported for unwrapping" (IllegalArgumentException).
Source
Thrown at server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java:347
return validationContext.getFailingConstraints();
}
@Override
public final BeanDescriptor getConstraintsForClass(Class<?> clazz) {
return beanMetaDataManager.getBeanMetaData( clazz ).getBeanDescriptor();
}
@Override
public final <T> T unwrap(Class<T> type) {
//allow unwrapping into public super types; intentionally not exposing the
//fact that ExecutableValidator is implemented by this class as well as this
//might change
if ( type.isAssignableFrom( Validator.class ) ) {
return type.cast( this );
}
throw LOG.getTypeNotSupportedForUnwrappingException( type );
}
@Override
public ExecutableValidator forExecutables() {
return this;
}
private ValidationContextBuilder getValidationContextBuilder() {
return new ValidationContextBuilder(
constraintValidatorManager,
constraintValidatorFactory,
validatorScopedContext,
TraversableResolvers.wrapWithCachingForSingleValidation( traversableResolver, validatorScopedContext.isTraversableResolverResultCacheEnabled() ),
constraintValidatorInitializationContext
);
}
private void sanityCheckPropertyPath(String propertyName) {View on GitHub (pinned to d44925c47c)
Solutions
- Unwrap to javax.validation.Validator or HibernateValidator's concrete Validator class if provider internals are needed
- Remove the unwrap call and use only the standard Validator API
- Check provider capabilities before unwrap
Example fix
// before MyValidatorImpl impl = validator.unwrap(MyValidatorImpl.class); // after org.hibernate.validator.HibernateValidator hv = validator.unwrap(org.hibernate.validator.HibernateValidator.class);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!org.hibernate.validator.HibernateValidator.class.isAssignableFrom(targetType)) { throw new IllegalArgumentException("Unsupported unwrap type: " + targetType); } Type guard
boolean isUnwrappable(Class<?> t) { return t != null && t.isAssignableFrom(javax.validation.Validator.class); } Try / catch
try { return validator.unwrap(type); } catch (IllegalArgumentException e) { return validator; } Prevention
- Only unwrap to types the provider documents as supported
- Use the standard Validator API instead of provider internals where possible
When it happens
Trigger: Calling validator.unwrap(SomeProviderSpecificClass.class) where SomeProviderSpecificClass is not the Hibernate Validator implementation itself, e.g. trying to unwrap to a custom class or to the wrong provider's type.
Common situations: Porting code between Bean Validation providers (e.g. from Apache BVal to Hibernate Validator) and keeping provider-specific unwrap calls; attempting to access provider internals.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unable to reach the property to validate.
- Invalid property path.
- The group must not be null.
- 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/bd435b2543bb95ec.
Report an issue: GitHub.