spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

Global Validation Errors are lost in RepositoryConstraintViolationExceptionMessage [DATAREST-832]

Open spring-projects-issues opened this issue 9 years ago • 2 comments

Pablo Andrés Grisafi opened DATAREST-832 and commented

RepositoryConstraintViolationExceptionMessage only uses field errors to create violation errors From the constructor:

for (FieldError fieldError : violationException.getErrors().getFieldErrors()) {

So global errors (the one you add with errors.reject instead of errors.rejectValue or ValidationUtils.rejectIf) are not mapped to ValidationError's, and do not show in json response

Or am I doing something wrong?


Affects: 2.5.1 (Hopper SR1)

6 votes, 8 watchers

spring-projects-issues avatar May 24 '16 14:05 spring-projects-issues

René Reitmann commented

We have just upgraded spring boot from 1.3.6 to 1.4.1 (=> data-rest from 2.4.4 to 2.5.3) and now this issue becomes a bigger problem. We use JSR-303 validation and have configured the ValidatingRepositoryEventListener to validate with LocalValidatorFactoryBean beforeCreate and beforeSave. Class level JSR-303 annotations do now result in "global" errors which are therefore not sent to the client anymore. If I rollback to 1.3.6 I can see that class level annotations result in field errors with empty property name. Have there been any changes in Spring Core which might have caused this?

spring-projects-issues avatar Oct 18 '16 12:10 spring-projects-issues

This is still an issue in 3.4.3

@odrotbohm thoughts?

loesak avatar Aug 22 '25 22:08 loesak