mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
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:
1 parent
05153b30be
commit
eca2199de6
2 files changed
+75
-1
No files matched your search
@@ -1903,7 +1903,13 @@ public class S3Controller {
|
||||
private List<CompletedPart> parseCompleteMultipartBody(String xml) {
|
||||
List<Map<String, String>> parts = XmlParser.extractGroups(xml, "Part");
|
||||
if (parts.isEmpty()) {
|
||||
throw malformedCompleteMultipartXml();
|
||||
if (xml == null || xml.isEmpty()) {
|
||||
throw emptyCompleteMultipartXml();
|
||||
}
|
||||
if (!"CompleteMultipartUpload".equals(XmlParser.rootElementName(xml))) {
|
||||
throw malformedCompleteMultipartXml();
|
||||
}
|
||||
throw emptyCompleteMultipartXml();
|
||||
}
|
||||
List<CompletedPart> completedParts = new ArrayList<>();
|
||||
for (Map<String, String> part : parts) {
|
||||
@@ -1927,6 +1933,10 @@ public class S3Controller {
|
||||
return new AwsException("MalformedXML", "The XML you provided was not well-formed.", 400);
|
||||
}
|
||||
|
||||
private static AwsException emptyCompleteMultipartXml() {
|
||||
return new AwsException("InvalidRequest", "You must specify at least one part", 400);
|
||||
}
|
||||
|
||||
private Map<Integer, S3Checksum> completedPartChecksums(List<CompletedPart> parts) {
|
||||
Map<Integer, S3Checksum> checksums = new HashMap<>();
|
||||
for (CompletedPart part : parts) {
|
||||
|
||||
Reference in new issue
Block a user