spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.17k stars 40.68k forks source link

Support 'server.error.include-*' functionality when 'spring.mvc.problemdetails.enabled' is active #33944

Open rozagerardo opened 1 year ago

rozagerardo commented 1 year ago

If we add support for the RFC 7807 Problem Details spec by including the spring.mvc.problemdetails.enabled=true property, then the server.error.include-* (e.g. server.error.include-binding-errors=always and server.error.include-message=always) properties are ignored, the response doesn't retrieve the relevant data.

IMO it would be suitable to allow mixing these two features to obtain an application/problem+json response with all the error information we want.

Note: this issue I submitted to the Spring Core project is somewhat related: https://github.com/spring-projects/spring-framework/issues/29849

bugix commented 1 year ago

To mitigate this, a way to handle MethodArgumentNotValidException and crafting our own ProblemDetail would be useful.