Skip to content

Wrong exception handling for @RequestParam of type boolean #36061

@mzatko

Description

@mzatko

If an invalid value is passed to @RequestParam of type boolean, an IllegalArgumentException is thrown, which is indistinguishable from other IllegalArgumentException exceptions.
This then leads to a 500 InternalServerError, which is clearly incorrect, as it is a clear example of a 400(BadRequest) error.

example

@GetMapping
ResponseEntity<Void> getException(@RequestParam(name = "bool", defaultValue = "false", required = false) boolean bool) {
   ...
}

then pasing GET http://server:port/?bool=dummy

causes 500 internalServerError

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions