Skip to content

S3Client PutObjectCommand prepending XML declaration to documents #7550

@dmcmullen

Description

@dmcmullen

Checkboxes for prior research

Describe the bug

Starting in version 3.931.0 of @aws-sdk/client-s3, the PutObjectCommand is unexpectedly prepending <?xml version="1.0" encoding="UTF-8"?> to documents when the ContentType is set to application/xml.

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

v24.11.0

Reproduction Steps

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

const client = new S3Client({ region: "us-east-1" });

const xmlContent = `<?xml version="1.0" encoding="UTF-8"?><root><element>test</element></root>`;

const command = new PutObjectCommand({
  Bucket: "my-bucket",
  Key: "test.xml",
  Body: xmlContent,
  ContentType: "application/xml",
});

await client.send(command);
// Downloaded content will have additional XML declaration prepended

Observed Behavior

The uploaded document has <?xml version="1.0" encoding="UTF-8"?> prepended to the original content.

Expected Behavior

The uploaded document should contain exactly the content provided, without any XML declaration prepended.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p1This is a high priority issuepotential-regressionMarking this issue as a potential regression to be checked by team memberresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions