From 3b5fcae07f36e4b2adde8a2862d94af2f4132581 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 22 Oct 2026 05:33:47 -0700 Subject: [PATCH] s3api: drop error-body assertions from the HeadBucket test HEAD responses carry no body since WriteResponse skips it, so the status code alone distinguishes a failed lookup from a missing bucket. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- weed/s3api/s3api_head_bucket_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/weed/s3api/s3api_head_bucket_test.go b/weed/s3api/s3api_head_bucket_test.go index 0c5cbf82ad..668ef8475c 100644 --- a/weed/s3api/s3api_head_bucket_test.go +++ b/weed/s3api/s3api_head_bucket_test.go @@ -5,7 +5,6 @@ import ( "net/http" "net/http/httptest" "path" - "strings" "testing" "github.com/gorilla/mux" @@ -56,19 +55,16 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) { name string filer *fakeLookupFiler wantCode int - wantBody string }{ { name: "transient lookup failure", filer: &fakeLookupFiler{lookupErr: status.Error(codes.Internal, "filer store unavailable")}, wantCode: http.StatusInternalServerError, - wantBody: "InternalError", }, { name: "missing bucket", filer: &fakeLookupFiler{}, wantCode: http.StatusNotFound, - wantBody: "NoSuchBucket", }, { name: "existing bucket", @@ -86,10 +82,11 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) { s3a.HeadBucketHandler(rr, req) if rr.Code != tc.wantCode { - t.Fatalf("status = %d, want %d: %s", rr.Code, tc.wantCode, rr.Body.String()) + t.Fatalf("status = %d, want %d", rr.Code, tc.wantCode) } - if tc.wantBody != "" && !strings.Contains(rr.Body.String(), tc.wantBody) { - t.Fatalf("body = %s, want %s", rr.Body.String(), tc.wantBody) + // HEAD responses never carry a body; the status code is the whole answer. + if rr.Body.Len() != 0 { + t.Fatalf("HEAD response must not have a body, got %q", rr.Body.String()) } }) }