ExAws.request attempting to parse XML with Jason when S3.put_bucket bucket exists
kipcole9 opened this issue · 0 comments
kipcole9 commented
- 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 1.13
- OTP 25
- Hackney 1.18.1
- Ex_aws 2.3.2
- Ex_aws_s2 2.3.2
- Minio as the S3 server
Current behavior
The response is in XML but there is an attempt to parse it with Jason.
# Create the bucket the first time is fine
iex(11)> ExAws.S3.put_bucket("test", "local") |> ExAws.request
{:ok,
%{
body: "",
headers: [
{"Accept-Ranges", "bytes"},
{"Content-Length", "0"},
{"Content-Security-Policy", "block-all-mixed-content"},
{"Location", "/test"},
{"Server", "MinIO"},
{"Strict-Transport-Security", "max-age=31536000; includeSubDomains"},
{"Vary", "Origin"},
{"Vary", "Accept-Encoding"},
{"X-Amz-Request-Id", "16FB232AB587C610"},
{"X-Content-Type-Options", "nosniff"},
{"X-Xss-Protection", "1; mode=block"},
{"Date", "Thu, 23 Jun 2022 03:45:54 GMT"}
],
status_code: 200
}}
# Attempting to create again raises an exception
# because there is an attempt to parse the XML response with Jason
iex(12)> ExAws.S3.put_bucket("test", "local") |> ExAws.request
** (UndefinedFunctionError) function Jason.decode/1 is undefined (module Jason is not available)
Jason.decode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>BucketAlreadyOwnedByYou</Code><Message>Your previous request to create the named bucket succeeded and you already own it.</Message><BucketName>test</BucketName><Resource>/test/</Resource><RequestId>16FB232C03089300</RequestId><HostId>b88ff3d2-77d5-4e69-b98b-2ef497518c32</HostId></Error>")
(ex_aws 2.3.2) lib/ex_aws/request.ex:122: ExAws.Request.client_error/2
(ex_aws 2.3.2) lib/ex_aws/request.ex:47: ExAws.Request.request_and_retry/7
(ex_aws 2.3.2) lib/ex_aws/operation/s3.ex:40: ExAws.Operation.ExAws.Operation.S3.perform/2
Expected behavior
The error is parsed correctly as XML