Note I am creating this post hoping that someone that works on R2 at Cloudflare finds this helpful.
In this post **** = redacted.
I was testing couple of S3 compatible storage providers, R2 being one of them. I have found
mc, the Minio client, to be a more natural tool to interact with any S3 compatible API.
I was testing uploads of larger files which would trigger a multipart upload. I tested against S3, Backblaze B2, and then finally R2. However when I got to testing R2, I was getting the following error from
Failed to copy `****`. The XML you provided was not well formed or did not validate against our published schema.
After digging a little into
mc and running
mc with debug logs, I found that the error message is returned by R2 along with a 400 Bad Request:
POST **** HTTP/1.1
User-Agent: MinIO (linux; amd64) minio-go/v7.0.27 mc/RELEASE.2022-06-26T18-51-48Z
Authorization: AWS4-HMAC-SHA256 Credential=****, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=****
HTTP/1.1 400 Bad Request
Date: Sun, 03 Jul 2022 10:15:53 GMT
Expect-Ct: max-age=604800, report-uri="****"
<Error><Code>MalformedXML</Code><Message>The XML you provided was not well formed or did not validate against our published schema.</Message></Error>
To check if the XML sent as part of the request was malformed or not, I modified
mc to output the XML before sending it to R2. I found the XML that was triggering the 400 was a
CompleteMultipartUpload message. After comparing with the AWS docs for this message, everything seemed to match up. Here is part of the XML:
At this point, I decided to try uploading the same file using the AWS CLI. This worked as expected. After inspecting the difference between the XML for
CompleteMultipartUpload sent by
aws s3, I noticed that the text body of
ETag was quoted by
aws s3 and left unquoted by
To make sure this was the problem, I modified
mc to quote the body of
ETag and tada, it worked! Here is the XML that worked:
So here is the question: is this something that needs to be changed on the R2 side, it looks like other S3 implementations including S3 itself can handle the
ETag body without needing quotes,
mc works fine with these other providers. On the other hand, I could raise this issue with
mc and maybe get the change for quoting the
ETag body upstreamed, but I feel skeptical about the latter?