From cb64570f13d1255efaf6b1f2ab940178318f5279 Mon Sep 17 00:00:00 2001 From: "Dr. Dominik Jain" Date: Thu, 24 Sep 2026 12:52:02 +0200 Subject: [PATCH 1/2] :bug: Fix text response construction from base64 data (#11422) Fixes SVG exports of shapes, as the export util method always produces a byte array, even for text data. --- mcp/packages/server/src/ToolResponse.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mcp/packages/server/src/ToolResponse.ts b/mcp/packages/server/src/ToolResponse.ts index db5babe4db..305fe6b5ff 100644 --- a/mcp/packages/server/src/ToolResponse.ts +++ b/mcp/packages/server/src/ToolResponse.ts @@ -10,12 +10,19 @@ export class TextContent implements TextItem { constructor(public text: string) {} /** - * @param data - Text data as string or as object (from JSON representation where indices are mapped to character codes) + * @param data - Text data as string or as object (wrapped base64 data or JSON representation of array where + * indices are mapped to character codes) */ public static textData(data: string | object): string { if (typeof data === "object") { - // convert object containing character codes (as obtained from JSON conversion of string) back to string - return String.fromCharCode(...(Object.values(data) as number[])); + // check for wrapped base64 data + if ("__type" in data && data["__type"] === "base64" && "data" in data && typeof data["data"] === "string") { + return Buffer.from(data["data"], "base64").toString("utf-8"); + } + // legacy fallback: assume object containing character codes (as obtained from direct JSON conversion) + else { + return String.fromCharCode(...(Object.values(data) as number[])); + } } else { return data; } @@ -84,8 +91,8 @@ export class TextResponse extends ToolResponse { } /** - * Creates a TextResponse from text data given as string or as object (from JSON representation where indices are mapped to - * character codes). + * Creates a TextResponse from text data given as string or as object (wrapped base64 data or JSON representation + * of array where indices are mapped to character codes). * * @param data - Text data as string or as object (from JSON representation where indices are mapped to character codes) */ From 773fc2295ebcb94a6dc01141ffdf5ae2a6ca5962 Mon Sep 17 00:00:00 2001 From: Filip Sajdak Date: Thu, 24 Sep 2026 14:48:43 +0200 Subject: [PATCH 2/2] :bug: Raise validation error for incompatible binfile export options (#10341) Requesting a binfile export with both `include-libraries` and `embed-assets` enabled threw a raw `IllegalArgumentException`, which the RPC layer surfaced to API clients as a generic `:server-error`/`:unexpected` (HTTP 500) with no actionable code -- the opaque failure reported in #7649 (perceived as an "empty" export). The two options are genuinely mutually exclusive, so the request is invalid input, not a server fault. Replace the raw throw in both the v1 and v3 export paths with `ex/raise :type :validation :code :incompatible-options`, matching how the rest of the binfile code reports bad input. Also fix the "mutally" -> "mutually" typo in the hint. Verified on a local devenv: the export RPC now returns `{:type :validation :code :incompatible-options}` instead of a 500, and valid single-option exports are unaffected. Adds a regression test. Fixes #7649 Signed-off-by: Filip Sajdak Signed-off-by: Andrey Antukh Co-authored-by: Claude Opus 4.8 Co-authored-by: Andrey Antukh --- backend/src/app/binfile/v1.clj | 5 +++-- backend/src/app/binfile/v3.clj | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/app/binfile/v1.clj b/backend/src/app/binfile/v1.clj index 5f1834cb74..be65b423c9 100644 --- a/backend/src/app/binfile/v1.clj +++ b/backend/src/app/binfile/v1.clj @@ -305,8 +305,9 @@ (defn write-export! [{:keys [::bfc/include-libraries ::bfc/embed-assets] :as cfg}] (when (and include-libraries embed-assets) - (throw (IllegalArgumentException. - "the `include-libraries` and `embed-assets` are mutally excluding options"))) + (ex/raise :type :validation + :code :incompatible-options + :hint "the `include-libraries` and `embed-assets` are mutually exclusive options")) (write-export cfg)) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index d8bab4d25c..cc488f6ab8 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -222,8 +222,9 @@ [{:keys [::bfc/embed-assets ::bfc/include-libraries] :as cfg} file-id] (when (and include-libraries embed-assets) - (throw (IllegalArgumentException. - "the `include-libraries` and `embed-assets` are mutally excluding options"))) + (ex/raise :type :validation + :code :incompatible-options + :hint "the `include-libraries` and `embed-assets` are mutually exclusive options")) (let [detach? (and (not embed-assets) (not include-libraries))] (db/tx-run! cfg (fn [cfg]