Why doesn't Spring Boot provide an on_param option for includeException?

Viewed 918

Spring Boot provides a default error response format with a number of properties, some of which must be opted into including:

{
  "timestamp": "2021-01-25T20:29:27.984+00:00",
  "status": 400,
  "error": "Bad Request",
  "exception": "org.springframework.http.converter.HttpMessageNotReadableException",
  "trace": "<multi-line stack trace goes here>",
  "path": "/path/to/endpoint"
}

Spring Boot provides a number of properties for whether to include the optional details in its error responses:

Key Default Value Description
server.error.include-binding-errors never When to include "errors" attribute.
server.error.include-exception false Include the "exception" attribute.
server.error.include-message never When to include "message" attribute.
server.error.include-stacktrace never When to include the "trace" attribute.

Three of these properties provide the on_param option to enable these features at request time by use of dedicated parameters:

http://www.example.com/path/to/endpoint?message&errors&trace

For some reason, the exception property is true/false, and does not provide a mechanism to enable it via a parameter.

Is there any documented reason why this inconsistency? Looking at the previously existing code, there was already prior art for the request parameter for stack traces. Neither the issue nor the pull request for the "includeException" option make any mention of the inconsistency.

I ask since I have an application that is returning the minimal information by default, but I would like to still have the option to view it on request. While the exception can be parsed out of the "trace" parameter, it's super verbose, and the "exception" parameter returns exactly that one bit of information.

0 Answers
Related