fix(s3-control): accept plain S3 ARN (arn:aws:s3:::bucket) in ListTagsForResource (#603)

Go SDK v2 and Terraform AWS provider v6 send arn:aws:s3:::<name> for
general-purpose buckets instead of the S3 Control form
arn:aws:s3:<region>:<account>:bucket/<name>. The plain ARN has no
region and no account segment, so the existing :bucket/ search found
nothing and returned a 400.

extractBucketName() now recognises both forms: the existing
:bucket/<name> form first, then the plain arn:<p>:s3:::<name> form
as a fallback.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-04-25 19:38:41 -05:00
1 parent 404b42bdc0
commit c7987ad1de
3 files changed
+82 -5

No files matched your search

@@ -180,4 +180,36 @@ class S3ControlUrlEncodedArnIntegrationTest {
assertS3ControlErrorResponse(response);
}
@Test
@Order(8)
@DisplayName("ListTagsForResource accepts plain S3 ARN (arn:aws:s3:::bucket) from Go SDK v2 / Terraform (#556)")
void listTagsForResourceWithPlainS3Arn() {
// Terraform AWS provider v6 / Go SDK v2 sends arn:aws:s3:::<name> for general-purpose buckets
String plainArn = "arn:aws:s3:::" + BUCKET;
given()
.header("x-amz-account-id", ACCOUNT)
.when()
.get("/v20180820/tags/" + plainArn)
.then()
.statusCode(200)
.contentType(containsString("xml"))
.body(containsString("<ListTagsForResourceResult"));
}
@Test
@Order(9)
@DisplayName("ListTagsForResource accepts URL-encoded plain S3 ARN from Go SDK v2 / Terraform (#556)")
void listTagsForResourceWithUrlEncodedPlainS3Arn() {
// Go SDK v2 percent-encodes colons: arn%3Aaws%3As3%3A%3A%3A<bucket>
String encodedPlainArn = "arn%3Aaws%3As3%3A%3A%3A" + BUCKET;
given()
.header("x-amz-account-id", ACCOUNT)
.when()
.get("/v20180820/tags/" + encodedPlainArn)
.then()
.statusCode(200)
.contentType(containsString("xml"))
.body(containsString("<ListTagsForResourceResult"));
}
}