aws/aws-sdk-java

Invalid character issue "&#x1b" in AmazonS3Client::listMultipartUploads

navinyashende opened this issue · 5 comments

Upcoming End-of-Support

  • I acknowledge the upcoming end-of-support for AWS SDK for Java v1 was announced, and migration to AWS SDK for Java v2 is recommended.

Describe the bug

Getting error while running listMultipartUpload method
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 599; Character reference "&#x1b" is an invalid XML character.

Expected Behavior

XML Response should be parsed without any issues. "&#x1b" is not a recommended escape character in xml.

Current Behavior

Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 599; Character reference "&#x1b" is an invalid XML character.

Reproduction Steps

Initialize s3 client and call listMultipartUploads

Possible Solution

Remove invalid character from XML response.

Additional Information/Context

No response

AWS Java SDK version used

1.12.725

JDK version used

openjdk version "1.8.0_402" OpenJDK Runtime Environment (build 1.8.0_402-b05) OpenJDK 64-Bit Server VM (build 25.402-b05, mixed mode)

Operating System and version

Fedora 40

@navinyashende use enconding-type:url in the ListMultipartUploads and see if it works.

        ListMultipartUploadsRequest request = ListMultipartUploadsRequest.builder()
                .bucket(BUCKET)
                .prefix(PREFIX)
                .encodingType(EncodingType.URL)
                .build();

@debora-ito We are using abortMultipartUploads method in TransferManager which internally calls listMultipartUploads in the AmazonS3.

I see. In this case, have you tried to manually url-encode the request attributes (like bucket and object name) before uploading? How the multipart upload is being done in the first place, is via TransferManager.upload()? Asking because I believe the SDK would encode bucket and object names in the upload.

@debora-ito The uploads are done from UI application via https://aws.amazon.com/sdk-for-javascript/. I was thinking if it would be possible to add encodingType in TransferManager class while making ListMultipartUploads request. This would make SDK immune to such issues.
https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/TransferManager.java#L1994

It would be nice but Java SDK v1 work is not being prioritized right now, ahead of the upcoming Maintenance Mode.

The workaround here is to manually encode the upload request attributes.