Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3tables test: improve error reporting on decoding failure

Chris Lu9f1dd5793994
diff --git a/test/s3tables/client.go b/test/s3tables/client.go
index 73ecf193b0..5806ee33c3 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)
}