Skip to content

Unable to parse S3 CreateMultipartUpload response with invalid XML characters #3496

@floppym

Description

@floppym

Describe the bug

botocore fails to process an S3 CreateMultipartUpload request when the response contains characters which are invalid according to XML 1.0. Commonly this happens when the S3 object key contains ASCII control characters.

Regression Issue

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

Expected Behavior

The response should be processed without error.

Current Behavior

An exception is raised:

Traceback (most recent call last):
  File "awscli/botocore/parsers.py", line 537, in _parse_xml_string_to_dom
xml.etree.ElementTree.ParseError: reference to invalid character number: line 2, column 122

Reproduction Steps

Using awscli, run a command like the following:

aws s3api create-multipart-upload --bucket mdg-test-20250618 --key $'test\u0007.txt' --debug

Possible Solution

  1. Extend AWS S3 service to not generate invalid XML in the CreateMultipartUpload response.
  2. Modify botocore to be more relaxed in its XML parsing code.

Additional Information/Context

debug.txt

SDK version used

aws-cli/2.27.37

Environment details (OS name and version, etc.)

Gentoo Linux

Metadata

Metadata

Assignees

Labels

bugThis issue is a confirmed bug.p2This is a standard priority issues3

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions