spring-projects / spring-projects/spring-data-rest
HttpMessageNotReadableException responds with a 400 (not 415) [DATAREST-413]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Dave Syer opened DATAREST-413 and commented
This appears to be a regression (or maybe a new "feature") because older versions of SDR didn't have this problem. There are actually potentially a few problems:
-
SDR takes responsibility for rendering
HttpMessageNotReadableException(instead of letting the user's app do it). That can be a courtesy because the default rendering in Spring MVC is horrid, but in a Spring Boot app it takes over from the default error rendering and ends up with less rich information for callers (you only get the exception message, no other information like path, status). -
Normally Spring MVC sends 415, and that seems more appropriate, since it is content negotiation that failed, not syntax.
-
The body of the response is the
HttpMessageNotReadableExceptionand that can be problematic for serialization (since the "cause" is generally "this"). Jacskon seems to handle it fine, but GSON does not, and I'm sure there are other message converters that would fail on a cycle
Affects: 2.2.1 (Evans SR1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.