Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 400 Bad request instead of 500 when JSON payload is well formed but has an invalid structure [SPR-8476] #13122

Closed
spring-projects-issues opened this issue Jun 21, 2011 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 21, 2011

Sébastien Launay opened SPR-8476 and commented

When the JSON payload is well formed but contains like a property that cannot be mapped to the target bean a JsonMappingException is thrown and then catch by DefaultHandlerExceptionResolver resulting in a 500.
This is not true for JsonParseException when the JSON is not well formed by wrapping the exception inside an HttpMessageNotReadableException thanks to #12097.

Unit test plus fix catching and wrapping the root exception JsonProcessingException can be found in the following patch.


Affects: 3.0.3, 3.1 M2

Attachments:

Referenced from: commits efaa941

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.1 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants