From 9f1dd5793994534ad29366de3d0a0e8d2ec77bd7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 28 Jan 2026 12:30:30 -0800 Subject: [PATCH] s3tables test: improve error reporting on decoding failure --- test/s3tables/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/s3tables/client.go b/test/s3tables/client.go index 73ecf193b..5806ee33c 100644 --- a/test/s3tables/client.go +++ b/test/s3tables/client.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" "github.com/seaweedfs/seaweedfs/weed/s3api/s3tables" @@ -39,9 +40,13 @@ func (c *S3TablesClient) doRequestAndDecode(operation string, reqBody interface{ defer resp.Body.Close() if resp.StatusCode != http.StatusOK { + bodyBytes, readErr := io.ReadAll(resp.Body) + if readErr != nil { + return fmt.Errorf("%s failed with status %d and could not read error response body: %v", operation, resp.StatusCode, readErr) + } var errResp s3tables.S3TablesError - if err := json.NewDecoder(resp.Body).Decode(&errResp); err != nil { - return fmt.Errorf("%s failed with status %d and could not decode error response: %v", operation, resp.StatusCode, err) + if err := json.Unmarshal(bodyBytes, &errResp); err != nil { + return fmt.Errorf("%s failed with status %d, could not decode error response: %v. Body: %s", operation, resp.StatusCode, err, string(bodyBytes)) } return fmt.Errorf("%s failed: %s - %s", operation, errResp.Type, errResp.Message) }