Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

response.sendError(statusCode, "error message") not working after upgrading springboot to 2.4.4

I am using AuthenticationEntryPoint to handle the Authentication issues.To deliver the exception reason to the end-user.

response.sendError(responseCode, "errorReason")

I recently upgraded the spring boot from "2.2.11.RELEASE" to "2.4.4". Since then it is not working anymore. It is not providing the "errorReason" in the response received by the client now. Is there any change recently introduced in spring-boot which I am missing?

like image 796
kushal agrawal Avatar asked Jun 19 '26 01:06

kushal agrawal


1 Answers

As of Spring Boot 2.3, the message is no longer included in the error response by default:

The error message and any binding errors are no longer included in the default error page by default. This reduces the risk of leaking information to a client. server.error.include-message and server.error.include-binding-errors can be used to control the inclusion of the message and binding errors respectively. Supported values are always, on-param, and never.

Setting server.error.include-message=always will restore Spring Boot 2.2's behavior.

like image 162
Andy Wilkinson Avatar answered Jun 21 '26 14:06

Andy Wilkinson