Closed tmulle closed 1 year ago
/cc @FroMage (resteasy-reactive), @Sgitario (resteasy-reactive), @geoand (resteasy-reactive), @stuartwdouglas (resteasy-reactive)
This is one for @FroMage
I'm having the same problem.
Quarkus version or git rev
3.0.0.Alpha6
I believe that this is working as intended.
The behaviour isn't specific to bean params, it's the same for normal @RestForm
parameters. Also, RESTEasy Classic and RESTEasy Reactive behave in the same way, according to my tests.
Basically, there are three ways how you could try to leave a form parameter empty in the request:
firstParam&secondParam&thirdParam
)firstParam=&secondParam=&thirdParam=
)From the request log in the original issue it looks like the second approach.
The first approach will lead to the parameter being extracted as null
.
The second and third approaches will be extracted as an empty string. This is mandated by the URL spec.
When extracting null
, the final value of the parameter will be null
. If the parameter is non-null, we run the converter, which for an Integer
-valued parameter is Integer.valueOf
. This will throw for an empty string, causing the 400 response.
@TwoFX Thanks for putting me on the right path: Changing my optional params to java.util.Optional
resolved my issue.
Describe the bug
Sorry if this is a simple question, but I'm having trouble with empty fields on my HTML pages being sent to Quarkus using the
@BeanParam
.My Bean has these fields:
And my endpoint is defined as:
But when I send an empty form, ie. the
Integer
fields are not filled from the form, I get a400 Bad Request
.Is this supported? I would've thought that the empty/missing fields would have just been NULL in my POJO and not throw and error. It works fine for the STRING fields, just not any of the Int,Double, etc.
I even tried using
@FormParam
with@DefaultValue
and still no luck:Expected behavior
Form should still post and parse and the missing/empty fields should be NULL
Actual behavior
I got a
400 Bad Request
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.16.3.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response