-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Declared broken for hash params with overlapping names #2195
Labels
Comments
Ouch. These look like real problems. Turn your example(s) into specs and see if you can fix'em? At least PR the specs. I think the other problem is real and needs to be similarly investigated. |
jcagarcia
added a commit
to jcagarcia/grape
that referenced
this issue
Nov 17, 2023
jcagarcia
added a commit
to jcagarcia/grape
that referenced
this issue
Nov 17, 2023
I've just sent a PR for solving this #2372 |
jcagarcia
added a commit
to jcagarcia/grape
that referenced
this issue
Nov 17, 2023
dblock
added a commit
that referenced
this issue
Nov 17, 2023
fix(#2195): Fix `declared` method for hash params with overlapping names
Solved in #2372 :) |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Upgrading from 1.3.3, noticed several bugs around
declared
. I think some of them already have issues/PRs (eg. #2112 #2001) but don't see this one:when passing
null
to hash params with unique names, the output is consistent (but still incorrect I think, but that's a different issue, see a note at the bottom):but when the param names overlap:
Present since 1.5.0, so it seems to be introduced by #2103, my guess is in this line
grape/lib/grape/dsl/inside_route.rb
Line 98 in 43936ac
Other than that:
Upgrading to >= 1.5.0 says behaviour changes only
when params are missing and include_missing=true
Upgrading to >= 1.3.3 says that
For now on, nil values stay nil values for all types, including arrays, sets and hashes.
so I assume changing
nil
to{}
in the first example whennull
is passed explicitly (andinclude_missing
isn'ttrue
as well) is an unintended behaviour as well?This also makes it impossible to set
nil
value for params withtype: Hash
when usingdeclared
. While it can be bypassed by using eg.types: [Hash, anything]
(single item triggers another bug where this timenil
is changed to[]
), it's only because the mentioned PR doesn't taketypes
under consideration at all, which is maybe yet another problem?The text was updated successfully, but these errors were encountered: