From 248c6cd6397e5c90e1df093478843a7933faef06 Mon Sep 17 00:00:00 2001 From: vigneshakaviki Date: Fri, 31 Jul 2026 22:49:39 -0700 Subject: [PATCH] fix: trim whitespace from bucket location --- bucket-cache.go | 3 ++- bucket-cache_test.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bucket-cache.go b/bucket-cache.go index 4e988e46c..a1e9150ea 100644 --- a/bucket-cache.go +++ b/bucket-cache.go @@ -23,6 +23,7 @@ import ( "net/http" "net/url" "path" + "strings" "github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/s3utils" @@ -114,7 +115,7 @@ func processBucketLocationResponse(resp *http.Response, bucketName string) (buck return "", err } - location := locationConstraint + location := strings.TrimSpace(locationConstraint) // Location is empty will be 'us-east-1'. if location == "" { location = "us-east-1" diff --git a/bucket-cache_test.go b/bucket-cache_test.go index 1965307e9..dab630fe7 100644 --- a/bucket-cache_test.go +++ b/bucket-cache_test.go @@ -309,6 +309,8 @@ func TestProcessBucketLocationResponse(t *testing.T) { }{ {"my-bucket", "", true, APIErrors[0], "us-east-1", nil, true}, {"my-bucket", "", false, APIError{}, "us-east-1", nil, true}, + {"my-bucket", "\n \n", false, APIError{}, "us-east-1", nil, true}, + {"my-bucket", " \neu-central-1\t", false, APIError{}, "eu-central-1", nil, true}, {"my-bucket", "EU", false, APIError{}, "eu-west-1", nil, true}, {"my-bucket", "eu-central-1", false, APIError{}, "eu-central-1", nil, true}, {"my-bucket", "us-east-1", false, APIError{}, "us-east-1", nil, true},