Skip to content

@RequestParam required true #50321

@GuidoFarport

Description

@GuidoFarport

Describe the bug

Like the title says the problem is into annotation @RequestParam(required=true)

Into spring you can specify if a request param is required or not and spring ( if required is set ) and it's not passed raise a BadRequestException.

But in quarkus i've this problematic point:

Required param seems it's not supported each time I added this the app gave me this exception:

Caused by: java.lang.IllegalArgumentException: Using required @RequestMapping is not supported. Offending method is 'it.test.controller.TestController#customException'
	at io.quarkus.spring.web.resteasy.reactive.deployment.SpringWebResteasyReactiveProcessor$1.transform(SpringWebResteasyReactiveProcessor.java:312)
	at org.jboss.resteasy.reactive.common.processor.transformation.AnnotationsTransformer.apply(AnnotationsTransformer.java:74)
	at org.jboss.jandex.AnnotationOverlayImpl$2.apply(AnnotationOverlayImpl.java:253)
	at org.jboss.jandex.AnnotationOverlayImpl$2.apply(AnnotationOverlayImpl.java:246)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at org.jboss.jandex.AnnotationOverlayImpl.getAnnotationsFor(AnnotationOverlayImpl.java:246)
	at org.jboss.jandex.AnnotationOverlayImpl.annotation(AnnotationOverlayImpl.java:129)
	at org.jboss.resteasy.reactive.common.processor.transformation.AnnotationStore.getAnnotation(AnnotationStore.java:52)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.collectEndpoints(EndpointIndexer.java:480)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:403)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:312)
	... 11 more

So i need to validate each request param field manually?

Another problem is the default value, if my request param is a boolean, and i don't pass it from the caller, Quarkus set a default value. Why?

It's totally wrong..

IE:

Image

In this example if you don't pass firstException param Quarkus set it to false.. but does not make sense because the param should be NULL so raise an exception..

Expected behavior

What I expect is that, since the RequestParam annotation is supported, its functions such as required and raising an exception if a required parameter is not passed are also supported.

Actual behavior

No response

How to Reproduce?

Download my project attached.

Run with ./mvnw quarkus:dev

Try to call the endpoint localhost:8080/test/exception without passing param firstException and can u see the default value problem

Try to add required=true into the TestController under @RequestParam annotation e you can see the error during startup

quarkus-request-param.zip

Output of uname -a or ver

No response

Output of java -version

21

Quarkus version or git rev

3.26.1

Build tool (ie. output of mvnw --version or gradlew --version)

mvnw quarkus:dev

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/springIssues relating to the Spring integrationkind/enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions