Skip to content

MalformedXML error trying to deleteObjects from S3 #6857

@spdaley

Description

@spdaley

Checkboxes for prior research

Describe the bug

I'm executing a node.js script to delete some files from an S3 bucket and I'm getting the following error:
MalformedXML: The XML you provided was not well-formed or did not validate against our published schema

This can be observed with the latest @aws-sdk/client-s3 and seems to have started with v3.698.0 (at least my sample script passes before that version).

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.17.0

Reproduction Steps

const { S3Client, DeleteObjectsCommand } = require("@aws-sdk/client-s3"); 
const client = new S3Client({});
const input = { 
  Bucket: "<replace_with_your_bucket>",
  Delete: { 
    Objects: [ 
      { 
        Key: "test.json", 
//        VersionId: "STRING_VALUE",
//        ETag: "STRING_VALUE",
        Size: 3000
      },
    ],
    Quiet: true
  }
};

const deleteStuff = async () => {
  const command = new DeleteObjectsCommand(input);
  const response = await client.send(command);
  return response;
}

deleteStuff();

If you comment out Size, it will work. If you enable either ETag or Size it will fail.

Observed Behavior

MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
    at throwDefaultError (/Users/seadaley/Downloads/test-s3/node_modules/@smithy/smithy-client/dist-cjs/index.js:844:20)
    at /Users/seadaley/Downloads/test-s3/node_modules/@smithy/smithy-client/dist-cjs/index.js:853:5
    at de_CommandError (/Users/seadaley/Downloads/test-s3/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4829:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/seadaley/Downloads/test-s3/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /Users/seadaley/Downloads/test-s3/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:485:18
    at async /Users/seadaley/Downloads/test-s3/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /Users/seadaley/Downloads/test-s3/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:263:18
    at async /Users/seadaley/Downloads/test-s3/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:110:22
    at async /Users/seadaley/Downloads/test-s3/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:138:14 {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '4F4T38E2VDAN70D4',
    extendedRequestId: 'Y/PAriWEA7r0cDYdVg0pW86bZoYUmFzw/DqtxpKJLdH36eyLwHkw+0RAJ4kVM+p+TWMb2YA/m+c=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'MalformedXML',
  RequestId: '4F4T38E2VDAN70D4',
  HostId: 'Y/PAriWEA7r0cDYdVg0pW86bZoYUmFzw/DqtxpKJLdH36eyLwHkw+0RAJ4kVM+p+TWMb2YA/m+c='
}

Expected Behavior

The script should not blow up with a MalformedXML error.

Possible Solution

No response

Additional Information/Context

In the sample program I provided, if you comment out Size, it will work. If you enable either ETag or Size it will fail.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepotential-regressionMarking this issue as a potential regression to be checked by team memberservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions