From c7d08f26443fa54dfda78fcc97dee70562787009 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Wed, 21 Jan 2026 17:31:14 -0800 Subject: [PATCH 1/2] fix(null-statuses): empty bodies handling --- apps/sim/tools/index.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/sim/tools/index.ts b/apps/sim/tools/index.ts index a112f30f55..9bda9f9b05 100644 --- a/apps/sim/tools/index.ts +++ b/apps/sim/tools/index.ts @@ -643,13 +643,22 @@ async function executeToolRequest( }) const responseHeaders = new Headers(secureResponse.headers.toRecord()) - const bodyBuffer = await secureResponse.arrayBuffer() + const nullBodyStatuses = new Set([101, 204, 205, 304]) - response = new Response(bodyBuffer, { - status: secureResponse.status, - statusText: secureResponse.statusText, - headers: responseHeaders, - }) + if (nullBodyStatuses.has(secureResponse.status)) { + response = new Response(null, { + status: secureResponse.status, + statusText: secureResponse.statusText, + headers: responseHeaders, + }) + } else { + const bodyBuffer = await secureResponse.arrayBuffer() + response = new Response(bodyBuffer, { + status: secureResponse.status, + statusText: secureResponse.statusText, + headers: responseHeaders, + }) + } } // For non-OK responses, attempt JSON first; if parsing fails, fall back to text @@ -693,11 +702,9 @@ async function executeToolRequest( throw errorToTransform } - // Parse response data once with guard for empty 202 bodies let responseData const status = response.status - if (status === 202) { - // Many APIs (e.g., Microsoft Graph) return 202 with empty body + if (status === 202 || status === 204) { responseData = { status } } else { if (tool.transformResponse) { From 58c89268f8f51b42eff5f12148c58ef0a392b566 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Wed, 21 Jan 2026 17:39:07 -0800 Subject: [PATCH 2/2] address bugbot comment --- apps/sim/tools/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/tools/index.ts b/apps/sim/tools/index.ts index 9bda9f9b05..c6647680ef 100644 --- a/apps/sim/tools/index.ts +++ b/apps/sim/tools/index.ts @@ -704,7 +704,7 @@ async function executeToolRequest( let responseData const status = response.status - if (status === 202 || status === 204) { + if (status === 202 || status === 204 || status === 205) { responseData = { status } } else { if (tool.transformResponse) {