Skip to content
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

server.error.include-binding-errors does not recognize MethodValidationResult exceptions #39858

Closed
rstoyanchev opened this issue Mar 8, 2024 · 1 comment
Labels
status: superseded An issue that has been superseded by another type: bug A general bug

Comments

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Mar 8, 2024

DefaultErrorAttributes recognizes BindingResult exceptions such as MethodArgumentNotValidException, and adds an "errors" field to the response. This is further controlled with the property server.error.include-binding-errors.

As of Spring Framework 6.1, built-in method validation can raise HandlerMethodValidationException instead when there are method parameter constraints. Beyond web endpoints, any Spring component with a validation proxy can raise MethodValidationException. Both implement MethodValidationResult.

BindingResult includes errors for a single method parameter (command object), while MethodValidationResult includes errors for all validated method parameters, either ParameterValidationResult (for constraints directly on method parameter) or ParameterErrors (constraints on properties of command object). The latter is the equivalent of a BindingResult for the method parameter when method validation is used.

DefaultErrorAttributes should support exceptions of type MethodValidationResult in addition to BindingResult. I think server.error.include-binding-errors could be extended to cover errors for all parameters, but it should at least properly handle and include any ParameterErrors, or otherwise there is no "errors" field at all as reported in spring-projects/spring-framework#32396.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 8, 2024
quaff added a commit to quaff/spring-boot that referenced this issue Mar 11, 2024
quaff added a commit to quaff/spring-boot that referenced this issue Mar 11, 2024
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 18, 2024
@wilkinsona wilkinsona added this to the 3.2.x milestone Mar 18, 2024
@wilkinsona wilkinsona changed the title server.error.include-binding-errors does not recognize MethodValidationResult exceptions server.error.include-binding-errors does not recognize MethodValidationResult exceptions Mar 18, 2024
quaff added a commit to quaff/spring-boot that referenced this issue Apr 12, 2024
quaff added a commit to quaff/spring-boot that referenced this issue Apr 13, 2024
@wilkinsona
Copy link
Member

Closing in favor of #39865.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
@wilkinsona wilkinsona removed this from the 3.2.x milestone Apr 22, 2024
@wilkinsona wilkinsona added the status: superseded An issue that has been superseded by another label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: bug A general bug
Projects
None yet
3 participants