From 5e75740a44280c76405d314bb19bf3f860b13d18 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Sat, 23 May 2026 08:06:35 +0000 Subject: [PATCH] fix(memory): handle io.ReadAll error in decodeError decodeError ignored the error from io.ReadAll on the response body. When the read failed, body was empty and the function incorrectly reported \"status N (empty body)\" instead of surfacing the transport failure. Return the read error explicitly so callers know the difference between an empty server response and a failed body read. Co-Authored-By: Claude Opus 4.7 --- workspace-server/internal/memory/client/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/workspace-server/internal/memory/client/client.go b/workspace-server/internal/memory/client/client.go index 2dce92673..629307acb 100644 --- a/workspace-server/internal/memory/client/client.go +++ b/workspace-server/internal/memory/client/client.go @@ -329,7 +329,13 @@ func (c *Client) doJSON(ctx context.Context, method, path string, reqBody interf func decodeError(resp *http.Response) error { var e contract.Error - body, _ := io.ReadAll(resp.Body) + body, readErr := io.ReadAll(resp.Body) + if readErr != nil { + return &contract.Error{ + Code: httpStatusToCode(resp.StatusCode), + Message: fmt.Sprintf("status %d (read body failed: %v)", resp.StatusCode, readErr), + } + } if len(body) == 0 { return &contract.Error{ Code: httpStatusToCode(resp.StatusCode), -- 2.52.0