fix: reject a ListBuckets bucket-region other than the gateway region

S3 never lists an empty result for another region: a valid region
other than the endpoint's own gets 400 InvalidArgument, "Requests with
bucket-region specified must be made to the corresponding regional
endpoint", with no ArgumentValue. The gateway is a single regional
endpoint, so it now does the same instead of clearing the listing.

Match the region case-insensitively like S3, and check an empty
bucket-region= too by looking for the query argument itself, since an
empty value is not a valid AWS region either.
This commit is contained in:
dualfroz committed 2026-10-05 20:42:30 +02:00
1 parent 5d293b1316
commit e1d2284906
7 files changed
+104 -56

No files matched your search

+10 -1
View File
@@ -74,9 +74,14 @@ const (
InvalidArgSSEInvalidEncryptionMethod
InvalidArgSSECRequiresTLS
InvalidArgUploadIdWithUploads
InvalidArgBucketRegionEndpoint
)
var invalidArgErrResponses = map[InvalidArgErrorCode]InvalidArgumentError{
InvalidArgBucketRegionEndpoint: {
Description: "Requests with bucket-region specified must be made to the corresponding regional endpoint",
ArgumentName: "bucket-region",
},
InvalidArgMaxBuckets: {
Description: "Argument max-buckets must be an integer between 1 and 10000.",
ArgumentName: "max-buckets",
@@ -386,9 +391,13 @@ func GetInvalidArgObjectOwnership(value string) InvalidArgumentError {
}
func GetInvalidArgBucketRegion(value string) InvalidArgumentError {
description := fmt.Sprintf("Argument value %s is not a valid AWS Region", value)
if value == "" {
description = "Argument value is not a valid AWS Region"
}
return InvalidArgumentError{
ArgumentName: "bucket-region",
// no ArgumentValue is returned for this error
Description: fmt.Sprintf("Argument value %s is not a valid AWS Region", value),
Description: description,
}
}