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

HttpMessageNotReadableException responds with a 400 (not 415) [DATAREST-413]

Open
#790 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
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:

  1. 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).

  2. Normally Spring MVC sends 415, and that seems more appropriate, since it is content negotiation that failed, not syntax.

  3. The body of the response is the HttpMessageNotReadableException and 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

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.