From 7217a105e1920d25edac2f575c2dad8a5ce7db1b Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Sat, 23 May 2026 08:48:46 +0000 Subject: [PATCH] fix(pgplugin): log JSON encode errors in writeJSON writeJSON ignored the error from json.NewEncoder(w).Encode(body). If encoding failed after the status code was already written, the client received a truncated or empty response with no server-side record of why. Log the error so operators can diagnose serialization issues. Co-Authored-By: Claude Opus 4.7 --- workspace-server/internal/memory/pgplugin/handlers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace-server/internal/memory/pgplugin/handlers.go b/workspace-server/internal/memory/pgplugin/handlers.go index 6627791be..578f0c1a8 100644 --- a/workspace-server/internal/memory/pgplugin/handlers.go +++ b/workspace-server/internal/memory/pgplugin/handlers.go @@ -3,6 +3,7 @@ package pgplugin import ( "encoding/json" "errors" + "log" "net/http" "strings" @@ -246,7 +247,9 @@ func (h *Handler) forget(w http.ResponseWriter, r *http.Request, id string) { func writeJSON(w http.ResponseWriter, status int, body interface{}) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) - _ = json.NewEncoder(w).Encode(body) + if err := json.NewEncoder(w).Encode(body); err != nil { + log.Printf("pgplugin: JSON encode error: %v", err) + } } func writeError(w http.ResponseWriter, status int, code contract.ErrorCode, message string, details map[string]interface{}) { -- 2.52.0