{"record":{"id":"bd435b2543bb95ec","repo":"theonedev/onedev","slug":"type-not-supported-for-unwrapping-type","errorCode":null,"errorMessage":"Type not supported for unwrapping: {type}","messagePattern":"Type not supported for unwrapping: (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java","lineNumber":347,"sourceCode":"\n\t\treturn validationContext.getFailingConstraints();\n\t}\n\n\t@Override\n\tpublic final BeanDescriptor getConstraintsForClass(Class<?> clazz) {\n\t\treturn beanMetaDataManager.getBeanMetaData( clazz ).getBeanDescriptor();\n\t}\n\n\t@Override\n\tpublic final <T> T unwrap(Class<T> type) {\n\t\t//allow unwrapping into public super types; intentionally not exposing the\n\t\t//fact that ExecutableValidator is implemented by this class as well as this\n\t\t//might change\n\t\tif ( type.isAssignableFrom( Validator.class ) ) {\n\t\t\treturn type.cast( this );\n\t\t}\n\n\t\tthrow LOG.getTypeNotSupportedForUnwrappingException( type );\n\t}\n\n\t@Override\n\tpublic ExecutableValidator forExecutables() {\n\t\treturn this;\n\t}\n\n\tprivate ValidationContextBuilder getValidationContextBuilder() {\n\t\treturn new ValidationContextBuilder(\n\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) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java#L329-L365","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nMyValidatorImpl impl = validator.unwrap(MyValidatorImpl.class);\n// after\norg.hibernate.validator.HibernateValidator hv = validator.unwrap(org.hibernate.validator.HibernateValidator.class);","handlingStrategy":"type-guard","validationCode":"if (!org.hibernate.validator.HibernateValidator.class.isAssignableFrom(targetType)) { throw new IllegalArgumentException(\"Unsupported unwrap type: \" + targetType); }","typeGuard":"boolean isUnwrappable(Class<?> t) { return t != null && t.isAssignableFrom(javax.validation.Validator.class); }","tryCatchPattern":"try { return validator.unwrap(type); } catch (IllegalArgumentException e) { return validator; }","preventionTips":["Only unwrap to types the provider documents as supported","Use the standard Validator API instead of provider internals where possible"],"tags":["hibernate-validator","bean-validation","unwrap","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}