diff --git a/apps/sim/tools/http/request.ts b/apps/sim/tools/http/request.ts index 91b9735e9dd..2803bfeb846 100644 --- a/apps/sim/tools/http/request.ts +++ b/apps/sim/tools/http/request.ts @@ -181,7 +181,6 @@ export const requestTool: ToolConfig = { transformResponse: async (response: Response) => { const contentType = response.headers.get('content-type') || '' - // Standard response handling const headers: Record = {} response.headers.forEach((value, key) => { headers[key] = value @@ -194,26 +193,6 @@ export const requestTool: ToolConfig = { }) const data = contentType.includes('application/json') ? JSON.parse(responseText) : responseText - // Check if this is a proxy response (structured response from /api/proxy) - if ( - contentType.includes('application/json') && - typeof data === 'object' && - data !== null && - data.data !== undefined && - data.status !== undefined - ) { - return { - success: data.success, - output: { - data: data.data, - status: data.status, - headers: data.headers || {}, - }, - error: data.success ? undefined : data.error, - } - } - - // Direct response handling return { success: response.ok, output: { diff --git a/apps/sim/tools/http/webhook_request.ts b/apps/sim/tools/http/webhook_request.ts index 89a89bcd150..4e058211927 100644 --- a/apps/sim/tools/http/webhook_request.ts +++ b/apps/sim/tools/http/webhook_request.ts @@ -85,24 +85,6 @@ export const webhookRequestTool: ToolConfig { }) }) +describe('HTTP tools report the real HTTP outcome', () => { + const stubbedHttpRequestTool = tools.http_request + + beforeEach(() => { + Object.assign(tools, { http_request: httpRequestTool, webhook_request: webhookRequestTool }) + mockValidateUrlWithDNS.mockResolvedValue({ isValid: true, resolvedIP: '93.184.216.34' }) + }) + + afterEach(() => { + vi.resetAllMocks() + tools.http_request = stubbedHttpRequestTool + Reflect.deleteProperty(tools, 'webhook_request') + }) + + it.each([ + ['http_request', { url: 'https://api.example.com/orders', method: 'POST', body: {} }], + ['webhook_request', { url: 'https://api.example.com/hooks', body: {} }], + ])( + '%s treats a 200 whose body has top-level status and data as a success', + async (toolId, params) => { + mockSecureFetchWithPinnedIP.mockResolvedValueOnce( + toSecureFetchResponse( + Response.json( + { status: 'success', data: { orderId: 'A-1001' } }, + { headers: { 'x-request-id': 'req-123' } } + ) + ) + ) + + const result = await executeTool(toolId, params, { skipPostProcess: true }) + + expect(result, result.error).toMatchObject({ + success: true, + output: { + status: 200, + data: { status: 'success', data: { orderId: 'A-1001' } }, + headers: expect.objectContaining({ 'x-request-id': 'req-123' }), + }, + }) + } + ) +}) + describe('File Parameter Normalization', () => { let cleanupEnvVars: () => void