-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
coerce_with should be called for params with nil value #2164
Conversation
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.
It looks good to me
This needs a README update to document behavior, CHANGELOG entry, and an UPGRADING note as the behavior has changed, even though it was undocumented. Do we think version should be bumped? |
For me the current behaviour was surprising -- i.e., coerce not being called for a declared value -- and it immediately registered as a bug. This new behaviour got introduced silently somewhere between 1.4.1 and 1.5.0 so from my point of view, it is more of a bug fix (to go back to the usual behaviour) then a behaviour change per se. If you see this as a backwards (original behaviour) compatible bug fix, semver says patch level shall be bumped. If you see it as correcting the backwards compatibility broken by a previous release then it says minor version. After saying all that, I don't think I am really at the position to suggest one way or another vis-a-vis version change so you have been warned. |
Makes sense, bug fix it is. Looking forward to all the README/UPGRADING/CHANGELOG parts. Thank you. |
The .md files are now updated. + I've added spec in case of an array |
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.
Good. I still would like clearer UPGRADING help.
aside note |
another aside note I feel like `type`: ->(val) { } I think providing different parsing rules for something should lead to creating a new type as using the same rules will lead to inconsistency from the client perspective, not sure though :) type: `Integer` # default rules
type: `Integer`, coerce_with: MyInt #another
type: `Integer`, corce_with: ->() #another |
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.
I'm good with this, but need to figure out what's up with CI.
https://github.com/ruby-grape/grape/pull/2164/checks?check_run_id=2039817421
So Line 258 in a43fea9
raise and it does not give a message String. It does pass a positional Hash argument though.And
It started failing most likely because of oracle/truffleruby@8348283, cc @bjfish The code in |
CI should be skipping truffleruby failures (we have this experimental=true in there, don't we?). Feel free to "fix" this by removing it if needed, and someone else can deal with it, I'll merge on green. I don't want to hold up a release either. |
@dblock That's due to the confusing I think you could switch to |
I currently see an issue with: Line 258 in a43fea9
The second to parameter to Here is a good example on how to pass custom data to an exception: I will also work on fixing the TruffleRuby failure here as it is an incompatibility. |
Good call @bjfish. Want to help fix the Grape implementation? |
Regarding the expected behavior pointed by @dblock
Yes, I believe so. A
nil
value is anil
value, not the absence of a parameter.Originally posted by @dblock in #2040 (comment)
Here is a first attemp to fix the behavior applied to the CustomTypeCoercer