Skip to content

Commit f645048

Browse files
committed
Filter unknown options before passing to Finch.request/3
Finch 0.21.0 validates the options keyword list and raises ArgumentError when unknown keys are passed. Since v0.21.0, the only allowed keys are :pool_timeout, :receive_timeout, :request_timeout, and :pool_strategy. Previously the entire options keyword list (including :finch_name) was forwarded to Finch.request/3, which now fails with: ** (ArgumentError) unknown keys [:finch_name] in [finch_name: MyFinch], the allowed keys are: [:pool_timeout, :receive_timeout, :request_timeout, :pool_strategy] Filter the options down to the keys Finch accepts before forwarding. No new tests were added because this was already caught by the current test suite after updating the finch dependency via `test/aws/http_client_test.exs:82` Fixes: #228 See: sneako/finch#365
1 parent ed8eab4 commit f645048

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/aws/http_client/finch.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ defmodule AWS.HTTPClient.Finch do
2020

2121
@behaviour AWS.HTTPClient
2222

23+
@finch_options [:pool_timeout, :receive_timeout, :request_timeout, :pool_strategy]
24+
2325
@impl AWS.HTTPClient
2426
def request(method, url, body, headers, options) do
2527
ensure_finch_running!()
2628

2729
finch_name = Keyword.get(options, :finch_name, AWS.Finch)
30+
finch_options = Keyword.take(options, @finch_options)
31+
2832
url = IO.iodata_to_binary(url)
2933
request = Finch.build(method, url, headers, body)
3034

31-
case Finch.request(request, finch_name, options) do
35+
case Finch.request(request, finch_name, finch_options) do
3236
{:ok, response} ->
3337
{:ok, %{status_code: response.status, headers: response.headers, body: response.body}}
3438

0 commit comments

Comments
 (0)