Use 400 Bad request instead of 500 when JSON payload is well formed but has an invalid structure [SPR-8476] #13122
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
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
The text was updated successfully, but these errors were encountered: