Skip to content

DefaultErrorAttributes doesn't populate errors for MethodValidationResult #42013

Closed as not planned
@sunruh

Description

@sunruh

GH-39865 added support for MethodValidationResult to DefaultErrorAttributes but it filters the list errors published in the result and used for counting to instances of ObjectError.

With a method signature (in a RestController) of e.g. public void method(@PathVariable @Pattern(regexp = "^a.*") String parameter), this results in

  • message = "Validation failed for method='public void <class>.method(java.lang.String)'. Error count: 0"
  • errors = []

This is due to the fact, that the MethodValidationResult generated by MethodValidationAdapter will contain instances of ParameterValidationResult that have resolvable errors of type DefaultMessageSourceResolvable (and not ObjectError).

Spring Boot 3.3.1
Spring Framework 6.1.10

Metadata

Metadata

Assignees

Labels

status: supersededAn issue that has been superseded by another

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions