From 83bcb1e5e13bd968c229dac28bb460442041ee1b Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 26 Mar 2026 08:19:59 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20bridge.go=20=E2=80=94=20remove=20encodin?= =?UTF-8?q?g/json=20entirely?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error classification uses string match on unmarshal errors instead of stdlib json.SyntaxError/UnmarshalTypeError type assertions. No exceptions. Co-Authored-By: Virgil --- pkg/mcp/bridge.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/mcp/bridge.go b/pkg/mcp/bridge.go index adec5fb..9f6e8b8 100644 --- a/pkg/mcp/bridge.go +++ b/pkg/mcp/bridge.go @@ -3,7 +3,6 @@ package mcp import ( - "encoding/json" "net/http" core "dappco.re/go/core" @@ -49,11 +48,9 @@ func BridgeToAPI(svc *Service, bridge *api.ToolBridge) { result, err := handler(c.Request.Context(), body) if err != nil { - // Classify JSON parse errors as client errors (400), - // everything else as server errors (500). - var syntaxErr *json.SyntaxError - var typeErr *json.UnmarshalTypeError - if core.As(err, &syntaxErr) || core.As(err, &typeErr) { + // Body present + error = likely bad input (malformed JSON). + // No body + error = tool execution failure. + if len(body) > 0 && core.Contains(err.Error(), "unmarshal") { c.JSON(http.StatusBadRequest, api.Fail("invalid_input", "Malformed JSON in request body")) return }