-
Notifications
You must be signed in to change notification settings - Fork 267
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
Template#expand to raise ArgumentError
multivalued query param
#284
Labels
Comments
Related to #282 |
Ah nice that worked! thanks. This can be closed 👍 |
Actually, I don't feel that this is a duplicate issue. |
However, I think the URI template spec doesn't define what behavior should be here. I think this should actually be an |
Currently fails like this when the mapping hash contains an array value $ ruby -raddressable/template -e 'Addressable::Template.new("/myPath{?params*}").expand(params: { bar: ["bar"] })'
/Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/uri.rb:409:in `rescue in encode_component': Can't convert Array into String. (TypeError)
raise TypeError, "Can't convert #{component.class} into String."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/uri.rb:399:in `encode_component'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:802:in `block (2 levels) in transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `each'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `map'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `block in transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `each'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `inject'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:595:in `block in expand'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:594:in `gsub!'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:594:in `expand'
from -e:1:in `<main>'
/Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/uri.rb:406:in `encode_component': undefined method `to_str' for ["bar"]:Array (NoMethodError)
component = component.to_str
^^^^^^^
Did you mean? to_set
to_s
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:802:in `block (2 levels) in transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `each'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `map'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:797:in `block in transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `each'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `inject'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:756:in `transform_capture'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:595:in `block in expand'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:594:in `gsub!'
from /Users/dentarg/.arm64_rubies/3.2.2/lib/ruby/gems/3.2.0/gems/addressable-2.8.4/lib/addressable/template.rb:594:in `expand'
from -e:1:in `<main>' |
dentarg
changed the title
Enhancement request - Template.expand() method to support multivalued query param
Template#expand to raise Jul 19, 2023
ArgumentError
multivalued query param
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the expand takes the mapping hash as input to construct the URI and from what I understand, doesn't look like it supports multivalued attribute? Example: I am trying to construct URI with the following mapping hash. Consider the Base path to be
/myPath
and if I call the expand method as follows
which should be translated to
/myPath?service=a&service=b&id=abc
Is it considered a valid enhancement to support or is there any other method which would allow to me to do what I need? I can issue a pull request if the change is valid. Thanks.
The text was updated successfully, but these errors were encountered: