fix(s3): return empty LocationConstraint for us-east-1 buckets (#336)

This commit is contained in:
Christine Nguyen authored and GitHub committed 2026-04-11 10:29:22 -05:00
1 parent 7b28155e26
commit 5ca47a5593
2 files changed
+60 -9

No files matched your search

@@ -1147,16 +1147,17 @@ public class S3Controller {
private Response handleGetBucketLocation(String bucket) {
String region = s3Service.getBucketRegion(bucket);
if (region == null) {
region = regionResolver.getDefaultRegion();
XmlBuilder xml = new XmlBuilder()
.raw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
if (region == null || "us-east-1".equals(region)) {
xml.start("LocationConstraint", AwsNamespaces.S3)
.end("LocationConstraint");
} else {
xml.start("LocationConstraint", AwsNamespaces.S3)
.raw(XmlBuilder.escape(region))
.end("LocationConstraint");
}
String xml = new XmlBuilder()
.raw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.start("LocationConstraint", AwsNamespaces.S3)
.raw(XmlBuilder.escape(region))
.end("LocationConstraint")
.build();
return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
return Response.ok(xml.build()).type(MediaType.APPLICATION_XML).build();
}
// --- Bucket Tagging ---