Skip to content

MethodArgumentNotValidException should include BindingResult errors in ProblemDetail #29849

Closed as not planned
@rozagerardo

Description

@rozagerardo

Affects: 6.0.3


After migrating to Boot 3 in my Boot application that has a @ControllerAdvice extending ResponseEntityExceptionHandler, my application started retrieving Errors using the ProblemDetail spec, overriding Boot's Error Handling mechanism.

All good up to that point, but my input validations are not retrieving the validation messages anywhere.

For example, I might have this constraint in my DTO:

@NotNull(message = "a custom validation error")
Long foo,

But the response for a request sending a null value for this field looks as follows:

{
    "type": "about:blank",
    "title": "Bad Request",
    "status": 400,
    "detail": "Invalid request content.",
    "instance": "/bar"
}

Shouldn't the detail contain the validation message, or, since there can be a number of binding errors, be included as an ProblemDetail.properties entry, resulting in an extra response body field?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions