ex-aws / ex_aws

A flexible, easy to use set of clients AWS APIs for Elixir
https://hex.pm/packages/ex_aws
MIT License
1.27k stars 526 forks source link

Support passing headers #832

Closed jacobsmith closed 2 years ago

jacobsmith commented 2 years ago

Passing Headers, such as If-Match, was previously causing issues. This is because the following code was executing when passing an array of header values:

  def retrieve_runtime_value(values, config) when is_list(values) do
    values
    |> Stream.map(&retrieve_runtime_value(&1, config))
    |> Enum.find(& &1)
  end

which destructured the data from [{ "header-name", "header-value"}] to { "header-name", "header-value"} (note that it is no longer a list containing a tuple, but rather simply a tuple.

This caused issues later when trying to build up the headers to send in the request. Abbreviated for simplicity, we had:

headers = { "some-key", "some-value" }
headers = [ defaultHeaders | headers ]

Because headers was no longer a List, the headers variable now contains an improper List.

This change passes config.headers through to the underlying functions without destructuring it first.

bernardd commented 2 years ago

Thanks @jacobsmith - would you be able to add a test case to cover this please?

jacobsmith commented 2 years ago

Sure thing @bernardd

jacobsmith commented 2 years ago

@bernardd just added a very simple test. Let me know if there's a better place to add the test. Thanks!

anthonator commented 2 years ago

@bernardd is there anything else we can do to help move this along?

bernardd commented 2 years ago

Hey - sorry, been super busy with work. I'm hoping to catch up on this and other items this weekend.

jacobsmith commented 2 years ago

@bernardd No worries - thanks for all your work on this/these libraries! We're currently running a fork with this one patch applied, so definitely not a blocker for us, but for obvious reasons we don't want to maintain a fork forever (:

bernardd commented 2 years ago

Thanks again @anthonator and apologies for the delay getting this in.

anthonator commented 2 years ago

@jacobsmith is the guy to thank but thanks for getting this merged in @bernardd!!!

jacobsmith commented 2 years ago

Thanks @bernardd !

bernardd commented 2 years ago

Whoops - thanks @jacobsmith :)