This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 26a74f7d672 HDDS-17599. S3G: DELETE with empty uploadId deletes the 
object instead of failing as an abort (#11859)
26a74f7d672 is described below

commit 26a74f7d6724bde49c4bb3f74a4a9613bb5dca7d
Author: Ritesh H Shukla <[email protected]>
AuthorDate: Sat Oct 31 23:32:48 2026 -0700

    HDDS-17599. S3G: DELETE with empty uploadId deletes the object instead of 
failing as an abort (#11859)
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java   | 17 +++++++++++++++
 .../ozone/s3/endpoint/MultipartKeyHandler.java     |  7 ++++++-
 .../hadoop/ozone/s3/endpoint/TestObjectDelete.java | 24 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
 
b/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
index 09314f019b2..036d34d9234 100644
--- 
a/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
+++ 
b/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
@@ -755,6 +755,23 @@ public void 
testDeleteObjectIfMatchWildcardMissingKeyFail() {
         b -> b.bucket(bucketName).key(keyName)));
   }
 
+  @Test
+  public void testAbortMultipartUploadWithEmptyUploadIdKeepsObject() {
+    final String bucketName = getBucketName();
+    final String keyName = getKeyName();
+    s3Client.createBucket(b -> b.bucket(bucketName));
+    PutObjectResponse putResponse = s3Client.putObject(
+        b -> b.bucket(bucketName).key(keyName), RequestBody.fromString("bar"));
+
+    S3Exception exception = assertThrows(S3Exception.class,
+        () -> s3Client.abortMultipartUpload(b -> 
b.bucket(bucketName).key(keyName).uploadId("")));
+
+    assertEquals(404, exception.statusCode());
+    assertEquals("NoSuchUpload", exception.awsErrorDetails().errorCode());
+    HeadObjectResponse headObjectResponse = s3Client.headObject(b -> 
b.bucket(bucketName).key(keyName));
+    assertEquals(putResponse.eTag(), headObjectResponse.eTag());
+  }
+
   @Test
   public void testGetObjectIfMatch() {
     final String bucketName = getBucketName();
diff --git 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/MultipartKeyHandler.java
 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/MultipartKeyHandler.java
index 02263550c3a..70d17ed4b9e 100644
--- 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/MultipartKeyHandler.java
+++ 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/MultipartKeyHandler.java
@@ -78,7 +78,7 @@ Response 
handleDeleteRequest(ObjectEndpoint.ObjectRequestContext context, String
       throws IOException, OS3Exception {
 
     final String uploadId = queryParams().get(QueryParams.UPLOAD_ID);
-    if (StringUtils.isEmpty(uploadId)) {
+    if (uploadId == null) {
       // not MPU -> let next handler run
       return null;
     }
@@ -86,6 +86,11 @@ Response 
handleDeleteRequest(ObjectEndpoint.ObjectRequestContext context, String
     context.setAction(S3GAction.ABORT_MULTIPART_UPLOAD);
 
     try {
+      if (uploadId.isEmpty()) {
+        // An empty uploadId names no upload. Letting the next handler run 
would turn this abort into a delete of the
+        // committed key.
+        throw newError(S3ErrorTable.NO_SUCH_UPLOAD, uploadId);
+      }
       Response r = abortMultipartUpload(context.getBucketName(), keyPath, 
uploadId);
 
       
getMetrics().updateAbortMultipartUploadSuccessStats(context.getStartNanos());
diff --git 
a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectDelete.java
 
b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectDelete.java
index 00114e3977c..e8b2a7b0b34 100644
--- 
a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectDelete.java
+++ 
b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectDelete.java
@@ -17,10 +17,12 @@
 
 package org.apache.hadoop.ozone.s3.endpoint;
 
+import static 
org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.abortMultipartUpload;
 import static 
org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.assertErrorResponse;
 import static 
org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.assertStatus;
 import static org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.delete;
 import static org.apache.hadoop.ozone.s3.endpoint.EndpointTestUtils.put;
+import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_UPLOAD;
 import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.PRECOND_FAILED;
 import static org.apache.hadoop.ozone.s3.util.S3Consts.IF_MATCH_HEADER;
 import static org.apache.hadoop.ozone.s3.util.S3Consts.X_AMZ_CONTENT_SHA256;
@@ -132,4 +134,26 @@ void testDeleteIfMatchWildcardForMissingKey() throws 
IOException {
 
     assertErrorResponse(PRECOND_FAILED, () -> delete(rest, "b1", "missing"));
   }
+
+  @Test
+  void testDeleteWithEmptyUploadIdKeepsKey() throws IOException, OS3Exception {
+    OzoneClient client = new OzoneClientStub();
+    client.getObjectStore().createS3Bucket("b1");
+
+    OzoneBucket bucket = client.getObjectStore().getS3Bucket("b1");
+    HttpHeaders headers = mock(HttpHeaders.class);
+    
when(headers.getHeaderString(X_AMZ_CONTENT_SHA256)).thenReturn("UNSIGNED-PAYLOAD");
+
+    ObjectEndpoint rest = EndpointBuilder.newObjectEndpointBuilder()
+        .setClient(client)
+        .setHeaders(headers)
+        .build();
+
+    assertStatus(HttpStatus.SC_OK, () -> put(rest, "b1", "key1", "content"));
+
+    // DELETE ?uploadId= aborts an upload that does not exist; it must not 
delete the committed key.
+    assertErrorResponse(NO_SUCH_UPLOAD, () -> abortMultipartUpload(rest, "b1", 
"key1", ""));
+
+    assertNotNull(bucket.getKey("key1"));
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to