Skip to content

QueryValue conversion errors are discarded since 4.10.0 #12238

@kristoisberg

Description

@kristoisberg

Expected Behavior

Providing an inconvertible value to a @QueryValue results in an error message showing the conversion error, e.g. attempting to convert a string to an integer shows the following error message: "Failed to convert argument [count] for value [a] due to: For input string: "a"".

Actual Behaviour

Providing an inconvertible value to a @QueryValue results in an error message indicating that the input is missing: "Required QueryValue [count] not specified".

Steps To Reproduce

MCVE:

@Controller
public class TestController {

    @Get
    public String helloWorld(@QueryValue(value = "count") Integer count) {
        return "Hello World";
    }
}

Hitting this endpoint with ?count=a results in the error message "Failed to convert argument [count] for value [a] due to: For input string: "a"" in Micronaut 4.9.4, but upgrading Micronaut to the 4.10 minor version results in the error usually shown for missing values: "Required QueryValue [count] not specified".

This change was caused by #11787, which discards the result of bindSimpleResult here if a value was not found, even though it might contain a conversion error.

Environment Information

No response

Example Application

No response

Version

4.10.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions