fix(s3): answer InvalidRequest for CompleteMultipartUpload with no parts (#5759)

CompleteMultipartUpload with an empty or absent parts list answered 400
MalformedXML. AWS and LocalStack answer 400 InvalidRequest with the message
"You must specify at least one part". A body that is not well-formed XML
still answers MalformedXML.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
Matheus Oliveira authored and GitHub committed 2026-10-15 21:58:05 -04:00
1 parent 05153b30be
commit eca2199de6
2 files changed
+75 -1

No files matched your search

@@ -118,6 +118,70 @@ class S3MultipartIntegrationTest {
.body(containsString("<Key>" + KEY + "</Key>"));
}
@Test
@Order(7)
void completeMultipartUploadWithoutPartsIsInvalidRequest() {
String key = "no-parts-complete.bin";
String newUploadId = given()
.when()
.post("/" + BUCKET + "/" + key + "?uploads")
.then()
.statusCode(200)
.extract().xmlPath().getString("InitiateMultipartUploadResult.UploadId");
// The CLI omits --multipart-upload and sends an empty body; the SDKs send an empty
// element. AWS answers both with InvalidRequest, while non-XML stays MalformedXML.
given()
.contentType("application/xml")
.body("")
.when()
.post("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId)
.then()
.statusCode(400)
.body("Error.Code", equalTo("InvalidRequest"))
.body("Error.Message", equalTo("You must specify at least one part"));
given()
.contentType("application/xml")
.body("<CompleteMultipartUpload/>")
.when()
.post("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId)
.then()
.statusCode(400)
.body("Error.Code", equalTo("InvalidRequest"))
.body("Error.Message", equalTo("You must specify at least one part"));
given()
.contentType("application/xml")
.body("<CompleteMultipartUpload></CompleteMultipartUpload>")
.when()
.post("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId)
.then()
.statusCode(400)
.body("Error.Code", equalTo("InvalidRequest"))
.body("Error.Message", equalTo("You must specify at least one part"));
given()
.contentType("application/xml")
.body(" \n ")
.when()
.post("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId)
.then()
.statusCode(400)
.body("Error.Code", equalTo("MalformedXML"));
given()
.contentType("application/xml")
.body("<CompleteMultipartUpload><Part></CompleteMultipartUpload>")
.when()
.post("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId)
.then()
.statusCode(400)
.body("Error.Code", equalTo("MalformedXML"));
given().when().delete("/" + BUCKET + "/" + key + "?uploadId=" + newUploadId).then().statusCode(204);
}
@Test
@Order(8)
void completeMultipartUpload() {