-
Notifications
You must be signed in to change notification settings - Fork 41.2k
ErrorController no longer called for response.sendError #29105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A small POC to showcase this: https://github.com/robtimus/spring-boot-test Tests succeed:
Tests fail:
Note: Java 8 may be needed, although I tested it with Java 11 and Java 17 as well. |
Maybe fixed by d9d161c, please try latest snapshot. |
@quaff the 404 test no longer fails for Spring Boot 2.6.2-SNAPSHOT. However, the 401 error (triggered by an AuthenticationException) still does not go through the error controller. If that's intentional I would have expected something in the release notes. |
I've done some deep debugging, and It appears that the |
@robtimus Denying access to the error controller on a 401 when the error page is secure is intended behavior. This was the inconsistency that was fixed in #26356 where an authorization error would deny access but an authentication error would not. The reason this is not in the release notes is because it was a bug fix. If you need to open access to the error controller, you can do so by adding |
Thanks, I have solved the issue in my test suite. |
In Spring Boot 2.5.7 and before, a not found error, AuthenticationException or AccessDeniedException (basically anything that uses
response.sendError
) goes through theErrorController
- eitherBasicErrorController
or a custom bean implementingErrorController
. In Spring Boot 2.6.0 and 2.6.1, this no longer occurs. That makes any customErrorController
bean useless for a lot of cases, and requires other ways of getting the same functionality.This is very easy to reproduce using non-custom code (apart from maybe a small main method). Put a breakpoint in class
BasicErrorController
, methoderror(HttpServletRequest request)
, and call any non-existing endpoint. In Spring Boot 2.5.7 the breakpoint is triggered, in 2.6.0 and 2.6.1 it is not.The text was updated successfully, but these errors were encountered: