The BasicErrorController doesn't look in the request attributes for a message if the exception is non-null, even if the message from the exception was empty or null. Arguably the message from sendError() should take precedence over an exception anyway (it's available as a request attribute, according to the servlet spec).

Comment From: wilkinsona

Arguably the message from sendError() should take precedence over an exception anyway (it's available as a request attribute, according to the servlet spec).

I agree. See #1731. Changing the precedence would fix that issue.

Comment From: chornyi

Did you consider making the precedence configurable? As it is now, when using the JSR-303 validations, all the caller gets is a BadRequest message with no details on which field is invalid. Or am I missing something and there is a way to get that information without writing custom error handlers?

Comment From: wilkinsona

@chornyi If you don't like the defaults, you can provide your own ErrorAttributes bean.

Comment From: dsyer

I don't think using JSR-303 per se will prevent you from seeing detailed field level errors (that's precisely the change we made here), but it might depend on how you are using it, whether that nformation is available at all. In any case I doubt if the change made here would have hidden any information, so reversing the priority wouldn't help you, unless I'm missing something. If you have an issue with the current code, please open a new ticket, anyway, and refer to this one if you need to.

Comment From: joseluis10101

@dsyer A while ago we implemented using 2.2 and including the message on sending worked very well, later we updated to Spring 2.4 but the message stopped being included in the response, I just verified that it also happens with 2.3.

My mistake, i just found that from SB 2.3 that is configurable by "server.error.include-message" parameter.

Comment From: dsyer

There’s not much point in commenting here. If there’s a behaviour change in recent versions it’s probably intentional, but open a new issue if you want to discuss.

Comment From: snicoll

@dsyer they updated their comment as they found the solution in the meantime. It's unrelated to this and a change of visibility in Spring Boot that is documented in the release notes.