Skip to content
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

Bad interaction between URITemplate and Faraday parameter parsing means dropped values from queries including multiple values for a parameter #114

Closed
ivoanjo opened this issue Feb 17, 2017 · 0 comments
Labels

Comments

@ivoanjo
Copy link
Contributor

ivoanjo commented Feb 17, 2017

The uri_template gem, which hyperclient uses to build urls, implements RFC6570, that expands a parameter in the {?foo*} format as ?foo=a&foo=b&foo=c.

Unfortunately, faraday's default argument parser (Faraday::Utils.default_params_encoder) is set to the NestedParamsEncoder which only considers parameters to be arrays if they have [] in the key.

The result is that values for a parameter are dropped in this process:

require 'faraday'
require 'uri_template'

Faraday::Utils.default_params_encoder.decode(
  URITemplate.new('http://example.com/{?foo*}').expand(foo: ['a', 'b']).split('?').last
)
=> {"foo"=>"b"}

And thus the resulting faraday request will be missing some of the values.

The solution is to use faraday's other parameter encoder (the FlatParamsEncoder).

I'm working on a PR to fix this, but wanted to open the issue to have something to reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants