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

Error when running the script "MalformedXML" #4

Open
gversmee opened this issue Oct 16, 2019 · 4 comments
Open

Error when running the script "MalformedXML" #4

gversmee opened this issue Oct 16, 2019 · 4 comments

Comments

@gversmee
Copy link

Hello, thank you very much for this script, this is exactly what I'm looking for. I'm trying to use it to upload a small object on S3. I'm running into the following issue:

Do you have the same issue on your end or is it my configuration?

Thanks for your help


> [email protected] start aws-s3-multipart-presigned-upload/backend
> node server.js

Example app listening on port 4000!
{
  Bucket: 'mybucket',
  Key: 'myobject',
  PartNumber: '1',
  UploadId: 'KAafi66SQfghLBIYD19RUZjgwe.47_BODU3uXFs10X1BKQ5VIez_HktLe2m3dTYC0i9hDwzOoSJ4ft5wKaZjdy3n10Brpxk2lq.qkJaW0uoqsUDbTHeoz3F7bMnGfD2i'
}
{
  params: {
    fileName: 'myobject',
    parts: [ [Object] ],
    uploadId: 'KAafi66SQfghLBIYD19RUZjgwe.47_BODU3uXFs10X1BKQ5VIez_HktLe2m3dTYC0i9hDwzOoSJ4ft5wKaZjdy3n10Brpxk2lq.qkJaW0uoqsUDbTHeoz3F7bMnGfD2i'
  }
} : body
{
  Bucket: 'mybucket',
  Key: 'myobject',
  MultipartUpload: { Parts: [ [Object] ] },
  UploadId: 'KAafi66SQfghLBIYD19RUZjgwe.47_BODU3uXFs10X1BKQ5VIez_HktLe2m3dTYC0i9hDwzOoSJ4ft5wKaZjdy3n10Brpxk2lq.qkJaW0uoqsUDbTHeoz3F7bMnGfD2i'
}
MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
    at Request.extractError [...]
 {
    message: 'The XML you provided was not well-formed or did not validate against our published schema',
    code: 'MalformedXML',
    region: null,
    time: 2019-10-16T20:42:21.454Z,
    requestId: '6F80BAEE1032B0F8',
    extendedRequestId: 'TUz6H3z/lq3RPHj3QioVw4R+g7lSjwvvqeC8XH6p2Fcz1ptXYk2pir9l8pGmjhabvKUnq0CQhYU=',
    cfId: undefined,
    statusCode: 400,
    retryable: false,
    retryDelay: 61.98304100596486
  },
  isOperational: true,
  code: 'MalformedXML',
  region: null,
  time: 2019-10-16T20:42:21.454Z,
  requestId: '6F80BAEE1032B0F8',
  extendedRequestId: 'TUz6H3z/lq3RPHj3QioVw4R+g7lSjwvvqeC8XH6p2Fcz1ptXYk2pir9l8pGmjhabvKUnq0CQhYU=',
  cfId: undefined,
  statusCode: 400,
  retryable: false,
  retryDelay: 61.98304100596486
}```
@chinying
Copy link

Hey @gversmee, do you happen to be using a browser extension that is blocking your PUT response's headers from S3?

I've faced this same issue / error code when Privacy Possum on Firefox was blocking my ETag response headers.
Screen Shot 2019-10-22 at 3 05 33 PM

The MalformedXML error you're seeing from your express.js backend is due to the ETag item missing from each corresponding Part in your completeMultipartUpload params.

You can check this for yourself by adding a console.log(uploadPartsArray) on the frontend at this line, and for my case, I noticed that the ETag was undefined.

Disabling the extension worked for my case.

@Ark-green
Copy link

I have the same issue, and the Etag is undefined but my browser is not blocking the headers.

@gversmee
Copy link
Author

Thanks for your comments. I tried with several browser, and deactivating the extension, but still got the same issue. Finally, I found this repo and ended up using it. It works fine.

@cgood92
Copy link

cgood92 commented Nov 12, 2019

I had this same issue, but it was due to a missing CORS configuration on the S3 bucket.

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <ExposeHeader>etag</ExposeHeader>
    <AllowedHeader>*</AllowedHeader>
  </CORSRule>
</CORSConfiguration>

Make sure to have etag as an exposed header.

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

4 participants