Skip to content

Multiple query parameters with same key get de-duped #1086

@ryanseys

Description

@ryanseys

Describe the bug

Bug

If you pass in multiple query parameters with the same key e.g. /v1/transactions?expand[]=data.flow_details&expand[]=data.entries , the resulting URL that is requested by the Stripe gem will only contain the last one i.e. /v1/transactions?expand[]=data.entries

Culprit

The culprit line is here where the query parameters are being converted into a Hash where the key of the Hash is the query parameter key, so only the last value is used.

query_params = Hash[URI.decode_www_form(u.query)].merge(query_params)

Workaround

Workaround in the case of expand[] parameters is to provide an index i.e. /v1/transactions?expand[0]=data.flow_details&expand[1]=data.entries so they don't get de-duped when converting to a Hash.

To Reproduce

stripe_client = Stripe::StripeClient.new
stripe_client.execute_request(
  :get, 
  "/v1/transactions?expand[]=data.flow_details&expand[]=data.entries",  # multiple expand[] parameters
  api_key: @api_key, 
  headers: request_options
)

Expected behavior

The resulting URL requested to Stripe contain all of the query parameters even if they have the same name.

Code snippets

No response

OS

macOS

Language version

Ruby 3.1.2

Library version

stripe-ruby 6.0.0

API version

2020-08-27

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions