spring-projects / spring-projects/spring-data-rest

Class level validation error messages are not sent to the client anymore [DATAREST-926]

Open
#1,289 2 comments 2 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

René Reitmann opened DATAREST-926 and 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 see the following issue: We do only use JSR-303 validations and have configured the ValidatingRepositoryEventListener to validate with LocalValidatorFactoryBean on beforeCreate and on beforeSave. After the upgrade, class level JSR-303 validation errors are not sent to the client anymore. However, field errors are sent to the client.

As mentionened here https://jira.spring.io/browse/DATAREST-832 there is (and has always been) a bug in RepositoryConstraintViolationExceptionMessage which only serializes field errors and no global errors. If I rollback spring boot to 1.3.6 (data-rest to 2.4.4) I can see that class level validation errors result in field errors with empty field name and are therefore serialized by RepositoryConstraintViolationExceptionMessage.

I assume that there has been a change in Spring core which causes class level validation errors to result in global errors and not in field errors anymore. Do you know something about such a change?


Affects: 2.5.4 (Hopper SR4)

Reference URL: https://jira.spring.io/browse/DATAREST-832

2 votes, 3 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.