fix(s3): return NoSuchTagSet from GetBucketTagging on untagged buckets (#4585)

GetBucketTagging returned 200 with an empty TagSet when a bucket had no tags, including after DeleteBucketTagging. AWS returns the NoSuchTagSet error instead. S3 Control ListTagsForResource still reports an empty list.
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-09-28 16:25:06 -04:00
1 parent fbbbf244af
commit 93ec5967fe
4 files changed
+54 -6

No files matched your search

@@ -257,10 +257,10 @@ class S3Test {
void deleteBucketTagging() {
s3.deleteBucketTagging(DeleteBucketTaggingRequest.builder().bucket(BUCKET).build());
GetBucketTaggingResponse response = s3.getBucketTagging(
GetBucketTaggingRequest.builder().bucket(BUCKET).build());
assertThat(response.tagSet()).isEmpty();
assertThatThrownBy(() -> s3.getBucketTagging(
GetBucketTaggingRequest.builder().bucket(BUCKET).build()))
.isInstanceOfSatisfying(S3Exception.class,
e -> assertThat(e.awsErrorDetails().errorCode()).isEqualTo("NoSuchTagSet"));
}
@Test
@@ -2119,6 +2119,9 @@ public class S3Controller {
private Response handleGetBucketTagging(String bucket) {
Map<String, String> tags = s3Service.getBucketTagging(bucket);
if (tags.isEmpty()) {
throw new AwsException("NoSuchTagSet", "The TagSet does not exist", 404);
}
return Response.ok(buildTaggingXml(tags)).type(MediaType.APPLICATION_XML).build();
}
@@ -1737,8 +1737,8 @@ class S3AuthEnforcementIntegrationTest {
.when()
.get("/" + BUCKET_CONFIG_BUCKET + "?tagging")
.then()
.statusCode(200)
.body(not(containsString("<Key>k</Key>")));
.statusCode(404)
.body(containsString("NoSuchTagSet"));
}
@Test
@@ -0,0 +1,45 @@
package io.github.hectorvent.floci.services.s3;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
@QuarkusTest
class S3BucketTaggingIntegrationTest {
@Test
void getBucketTaggingOnUntaggedBucketReturnsNoSuchTagSet() {
String bucket = "tagging-never-tagged";
given().when().put("/" + bucket).then().statusCode(200);
given()
.when()
.get("/" + bucket + "?tagging")
.then()
.statusCode(404)
.body(containsString("<Code>NoSuchTagSet</Code>"));
}
@Test
void getBucketTaggingAfterDeleteBucketTaggingReturnsNoSuchTagSet() {
String bucket = "tagging-tags-deleted";
given().when().put("/" + bucket).then().statusCode(200);
given()
.contentType("application/xml")
.body("<Tagging><TagSet><Tag><Key>team</Key><Value>backend</Value></Tag></TagSet></Tagging>")
.when()
.put("/" + bucket + "?tagging")
.then()
.statusCode(204);
given().when().delete("/" + bucket + "?tagging").then().statusCode(204);
given()
.when()
.get("/" + bucket + "?tagging")
.then()
.statusCode(404)
.body(containsString("<Code>NoSuchTagSet</Code>"));
}
}