Home > Enterprise >  Error response body is empty in Spring Boot 2.6
Error response body is empty in Spring Boot 2.6

Time:12-23

There is an application on Spring Web stack. I faced an unusal problem after the upgrading to the lastest Spring Boot 2.6.1.

The following code

@RestController
@RequestMapping("sample")
class SampleController {
    @PostMapping
    fun doSomething(@RequestBody body: Any): Any {
        error("Error!")
    }
}

used to produce the following error in earlier versions

{
    "timestamp": "2020-05-27T13:44:58.032 00:00",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Error!",
    "path": "/sample"
}

But after the upgrade the whole response body is empty. Not the message field which is could be fixed with server.error.inclide-message: always flag setting, but the whole body. The include-binding-errors: always flag has no effect as well.

I found no notes about that behavior in the Spring Boot changelog

CodePudding user response:

Have a look at this issue: https://github.com/spring-projects/spring-boot/issues/28953

If you permit access to the /error whitelabel page in your SecurityConfig it should work again. However, this seems to be a workaround as the issue is still in progress.

CodePudding user response:

So it was a bug in 2.6.0 and 2.6.1 version. Fixed in 2.6.2

  • Related