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

Sending empty list of objects with s3.deleteObjects causes a crash. #223

Closed
lalnuo opened this issue Apr 30, 2018 · 2 comments
Closed

Sending empty list of objects with s3.deleteObjects causes a crash. #223

lalnuo opened this issue Apr 30, 2018 · 2 comments
Assignees
Labels

Comments

@lalnuo
Copy link

lalnuo commented Apr 30, 2018

Hi! Following code will result an error:

s3.deleteObjects(
        {
          Bucket: config.BUCKET_NAME,
          Delete: {
            Objects: []
          }
        }
      );

Causes:

Uncaught TypeError: Cannot read property 'map' of undefined
      at xml2js.parseString (node_modules/s3rver/lib/controllers.js:114:45)
      at Parser.<anonymous> (node_modules/xml2js/lib/xml2js.js:489:18)
      at Parser.emit (domain.js:421:20)
      at SAXParser.onclosetag (node_modules/xml2js/lib/xml2js.js:447:26)
      at emit (node_modules/sax/lib/sax.js:640:35)
      at emitNode (node_modules/sax/lib/sax.js:645:5)
      at closeTag (node_modules/sax/lib/sax.js:905:7)
      at SAXParser.write (node_modules/sax/lib/sax.js:1306:13)
      at Parser.exports.Parser.Parser.parseString (node_modules/xml2js/lib/xml2js.js:508:31)
      at Parser.parseString (node_modules/xml2js/lib/xml2js.js:7:59)
      at Object.exports.parseString (node_modules/xml2js/lib/xml2js.js:540:19)
      at deleteObjects (node_modules/s3rver/lib/controllers.js:113:12)
      at req.pipe.data (node_modules/s3rver/lib/controllers.js:517:13)
      at ConcatStream.<anonymous> (node_modules/concat-stream/index.js:36:43)
      at ConcatStream.emit (domain.js:421:20)
      at finishMaybe (node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:620:14)
      at afterWrite (node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:482:3)
      at process._tickCallback (internal/process/next_tick.js:114:19)
@n1ru4l n1ru4l added the bug label Apr 30, 2018
@n1ru4l n1ru4l self-assigned this Apr 30, 2018
@n1ru4l n1ru4l closed this as completed in e47f309 May 2, 2018
@c24w
Copy link

c24w commented Jan 23, 2019

Whilst #224 has stopped the server from crashing, the real S3 actually rejects requests which contain an empty Objects array:

MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
    at Request.extractError (/var/task/node_modules/aws-sdk/lib/services/s3.js:585:35)

So the behaviour gives a false-positive compared to the real thing.

Here's where the schema is defined for the JS SDK (although I don't know which bit specifically enforces that Objects is not empty). Would it be significant effort to validate against the same schema in this project?

@kherock
Copy link
Collaborator

kherock commented Jan 24, 2019

@c24w we don't validate against those schemas directly (yet), but it shouldn't be difficult to handle this particular case. I think most of the maintainers, myself included, have been pretty busy lately, so a PR would be very welcome. I've opened #372 to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants