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

Issues with object name with characters that should be url encoded #647

Open
mmarini opened this issue Jul 29, 2019 · 0 comments
Open

Issues with object name with characters that should be url encoded #647

mmarini opened this issue Jul 29, 2019 · 0 comments

Comments

@mmarini
Copy link

mmarini commented Jul 29, 2019

  • Do not use the issues tracker for help or support (try Elixir Forum, Slack, IRC, etc.)
  • Questions about how to contribute are fine.

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
  • ExAws version mix deps |grep ex_aws

ex_aws 2.1.1 (Hex package) (mix)
locked at 2.1.1 (ex_aws) 1e4de210

ex_aws_sqs 2.0.1 (Hex package) (mix)
locked at 2.0.1 (ex_aws_sqs) 42b19229

ex_aws_s3 2.0.2 (Hex package) (mix)
locked at 2.0.2 (ex_aws_s3) c0258bbd

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

hackney 1.15.1 (Hex package) (rebar3)
locked at 1.15.1 (hackney) 9f8f471c

Current behavior

I'm trying to perform a head request on an object in a bucket I have access to:

ExAws.S3.head_object("test-bucket", "simples.wav") |> ExAws.request(aws_config)

which returns me the headers just fine.

If the request has a character that should be url encoded:

ExAws.S3.head_object("test-bucket", "b_+22222222_20190726T045247+0000_bf18e58a-0098-99fb-7dbb-be3539d8327a.wav") |> ExAws.request(aws_config)

I get a 404 error

If I url encode the object name

ExAws.S3.head_object("test-bucket", "b_%2B22222222_20190726T045247%2B0000_bf18e58a-0098-99fb-7dbb-be3539d8327a.wav") |> ExAws.request(aws_config)

I then get a 403 error

Expected behavior

I should get a 200 ok with the header details

{:ok, %{ headers: [ {"x-amz-id-2", "B9cWAN2B0szSy+Z4kw52gtzdqCxi70LmCN+g7nw/KNZtLWDv2CyU1MHdrdpzMpbiFk7pGv7RiU4="}, {"x-amz-request-id", "AF68FC0E0BBE2125"}, {"Date", "Fri, 26 Jul 2019 07:54:50 GMT"}, {"Last-Modified", "Fri, 26 Jul 2019 06:43:11 GMT"}, {"ETag", ""8d754d4e52dbb4e6613446f0d9832d91""}, {"x-amz-server-side-encryption", "AES256"}, {"Accept-Ranges", "bytes"}, {"Content-Type", "audio/x-wav"}, {"Content-Length", "1918444"}, {"Server", "AmazonS3"} ], status_code: 200 }}

What I've found

Event though the problem is taking place in ex-aws-s3, I think I've found the cause of my problems in the core ex-aws library

  1. ExAws.Auth.Utils.uri_encode replaces the '+' that are in the filename with a space. This is having the impact of producing an invalid signature. I think this is being done for query params at the end of the path, but is having an impact on the path itself

  2. ExAws.Request.Url.build doesn't url encode the path. I'm not sure if this should be done here at this level, or at the HttpClient level where the request is executed

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