-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TemporalParamConverter returns null if it has to convert empty string #42468
Conversation
I'm having problem getting the |
Have you installed the artifacts locally with |
Ah... It was in my face... It failed the first time for Gradle Model. I was going to deal with it after I got everything working for the PR :D I ran it again now and it seems like I need JDK 17 installed for it to run. I'll fix this tomorrow and try again. Thanks! |
@FroMage @geoand I was updating the tests, when I realized that just adding This breaks custom converters that throw on empty string and where users also use Optional as a parameter and expect to throw and not handle Optional on empty string. My guess would be that this is very uncommon. The upside is, that this applies to all types, not just temporal - e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels wrong to me. It special-cases Optional
, and does not solve the issue for any type that is not optional. Indeed the tests you added expect a 400
for a null
Date
.
In my opinion there are two alternatives possible:
- Either we decide that
foo=
is equivalent tofoo
not being set, and any value extracted for it should benull
, and we cannot make the difference between passing an empty string and not passing any value, in which case it'sResteasyReactiveRequestContext.get*Param()
should not return empty strings, butnull
values, and then every furtherParamConverter
will work properly, or - We declare that
foo=
should set it to an empty string (as is the case now, as opposed to anull
value) and so everyParamConverter
that exists has to handle empty strings specially, such as temporal values.
I'm not entirely sure what to do, TBH. Perhaps @geoand has an opinion?
I was about to disagree, because I thought I was being smart with null safety, but I completely forgot, that if no parameter is set, it will be null anyways. The problem of making The problem with |
Yeah, for strings, we might be able to use an empty string to disinguish:
So, really, IMO the interesting difference is between:
Note that this problem only happens for strings, because we have confusion between This does not apply to integers, booleans or any other type where the empty value is distinct from the "not set" value. For example, given an unboxed integer:
And given a boxed integer:
So I think that Therefore, I suggest we turn both This is what makes the most sense. And if people want to differenciate between |
Yep, completely agree. There are custom converters as well, but I would be surprised if anyone is relying on this behavior.
This makes the most sense to me as well. I'll make the changes shortly. |
I have done the changes. I have two more questions:
|
I think we should make the array parameters empty collections, if it's not already the case. I'm not sure how it makes sense to turn
That's fine IMO. |
This comment has been minimized.
This comment has been minimized.
The TCK complains about cookie params only, perhaps there's a bug in your PR, only for cookies? As for |
What do we do with |
Yeah, this is the only thing that makes sense for arrays of primitives anyways. |
It seems to be an issue with query parameters for the test setup... When client makes the request on the server, query parameter |
This comment has been minimized.
This comment has been minimized.
It took me more than I'm willing to admit, but I have confirmed this... As soon as I return null for Do I make a PR to TCK as well? This needs to be changed to include the same response as the else block, |
yeah, it's not right that a query param change would break cookie tests. Thta's just bad testing. |
Fix cookie param tests, that break because of the change of how empty query parameters are handled by resteasy -> quarkusio/quarkus#42468
Well, it was just a defensive branch that was never hit. I opened the pull request there: quarkusio/resteasy-reactive-testsuite#8 Once that is merged, the test should go through. |
@blazmrak Can you rebase, the other PR has been merged. |
…if the parameter is an empty string
@cescoffier I have rebased the changes. Sorry, I forgot about this PR. It was a while ago, but I think I still have to implement the handling of the arrays. I'll take a look over this PR again today and make the changes if necessary. |
This comment has been minimized.
This comment has been minimized.
@cescoffier I have implemented the feature and it passes the tests for vertx. However, I'm losing the battle with TCK tests... I have no idea in what world is this wrong:
I don't know how I could overlook that, nor how did I get the suite to pass with that change... I have probably undone the changes for query params when I was figuring the test suite out smh. Sorry for this fuckup... I have made the suite actually pass this time by moving the content of |
@FroMage any idea about the TCK? |
Sure. |
@FroMage I have submitted a PR |
This comment has been minimized.
This comment has been minimized.
I've restarted the tests |
This comment has been minimized.
This comment has been minimized.
@FroMage Same failure... The commit hash has to be updated to |
Status for workflow
|
@geoand you OK with this one? Shall I merge it? |
I think there was an update to the TCK in the meantime, that would be nice to include. Otherwise, it's good |
@geoand This PR should be on the latest commit quarkusio/resteasy-reactive-testsuite@2b26361
|
The latest commit on the testsuite is 0231b4a4c070d4899216bd6aa77c9a30f2129dd3 from a few days ago |
Ah, good point! |
Closes #40833