jamhall/s3rver

Reject deleteObjects requests which specify an invalid Objects field

Closed this issue · 1 comments

When using aws-sdk with the following input:

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

real S3 rejects the request complaining that it did not validate against the published schema

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)

Our existing implementation gives a false-positive by assuming an empty array when the field is not defined.

By the schema linked a above I'm not convinced that sending an empty array is actually invalid. Based on the example for #223, it seems like the JavaScript aws-sdk will actually strip the request of the Objects field if an empty array provided (in which case the implementation of #224 is actually invalid). We should double-check that sending a raw request to S3 with an empty Objects array still validates.