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

301 errors do not include the http response, unlike other errors #1030

Open
robpallotta opened this issue Feb 13, 2024 · 0 comments
Open

301 errors do not include the http response, unlike other errors #1030

robpallotta opened this issue Feb 13, 2024 · 0 comments

Comments

@robpallotta
Copy link

301 redirect errors do not include the raw http response the same way that other errors do. This prevents users from appropriately handling certain error cases, such as s3 redirects. The returned value should be consistent across all error types.

Environment

  • Elixir & Erlang versions (elixir --version):

Erlang/OTP 25 [erts-13.2.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.14.5 (compiled with Erlang/OTP 25)

  • ExAws version mix deps |grep ex_aws

ex_aws 2.5.1
ex_aws_s3 2.5.3

  • HTTP client version. IE for hackney do mix deps | grep hackney

hackney 1.20.1

Current behavior

301 redirect error is missing http response details, other error includes http response details:

ExAws.S3.get_object("bucket-in-another-region", "non-existent-file") |> ExAws.request
[warning] ExAws: Received redirect, did you specify the correct region?
{:error, {:http_error, 301, "redirected"}}

ExAws.S3.get_object("bucket-in-same-region", "non-existent-file") |> ExAws.request()
{:error,
 {:http_error, 404,
  %{
    body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NoSuchKey</Code><Message>The specified key does not exis$
    headers: [
      {"x-amz-request-id", "9Z70W9SJR886K7BY"},
      {"x-amz-id-2",
       "wZiIt5U9qQr3zZaM0J2c5eM9VKVXdA6ABqkFpma77/BPz999LpWXNVswJAqYcKTBt7QhsR22NKY="},
      {"Content-Type", "application/xml"},
      {"Transfer-Encoding", "chunked"},
      {"Date", "Tue, 13 Feb 2024 01:22:33 GMT"},
      {"Server", "AmazonS3"}
    ],
    status_code: 404
  }}}

Expected behavior

301 redirect error should include http response in the same way as the other error:

ExAws.S3.get_object("bucket-in-another-region", "non-existent-file") |> ExAws.request
[warning] ExAws: Received redirect, did you specify the correct region?
{:error,
 {:http_error, 301,
  %{
    body: ...ommitted...,
    headers: [
      {"x-amz-bucket-region", "us-east-1"},
      {"x-amz-request-id", "ZQN1XPKDKPKSJ887"},
      {"x-amz-id-2",
       "zZtkGSy3AxBOPv7JQPl7D9Q1CtQsdWsLUPGWtwPO4Ei7Brp1MDhsZbNTUEUi7yv7mKEpX/zC7TM="},
      {"Content-Type", "application/xml"},
      {"Transfer-Encoding", "chunked"},
      {"Date", "Mon, 12 Feb 2024 02:54:23 GMT"},
      {"Server", "AmazonS3"}
    ],
    status_code: 301
  }
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant