{"record":{"id":"3d6c97ba5b00facb","repo":"twentyhq/twenty","slug":"isstring-response-error-response-error-json-s","errorCode":null,"errorMessage":"isString(response.error) ? response.error : JSON.stringify(response.error)","messagePattern":"isString\\(response\\.error\\) \\? response\\.error : JSON\\.stringify\\(response\\.error\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts","lineNumber":127,"sourceCode":"        const resultData = isString(response.result)\n          ? response.result\n          : JSON.stringify(response.result, null, 2);\n        const language = isObject(response.result) ? 'json' : 'plaintext';\n\n        setHttpRequestTestData((prev) => ({\n          ...prev,\n          output: {\n            data: resultData,\n            status: response.status ?? 200,\n            statusText: response.statusText ?? 'OK',\n            headers: response.headers ?? {},\n            duration,\n            error: undefined,\n          },\n          language,\n        }));\n      } else {\n        throw new Error(\n          isString(response.error)\n            ? response.error\n            : JSON.stringify(response.error),\n        );\n      }\n    } catch (error) {\n      const duration = Date.now() - startTime;\n\n      const rawErrorMessage =\n        error instanceof Error ? error.message : t`HTTP request failed`;\n\n      const jsonParsedErrorMessage = parseJson(rawErrorMessage);\n\n      const errorMessage = isDefined(jsonParsedErrorMessage)\n        ? JSON.stringify(jsonParsedErrorMessage, null, 2)\n        : rawErrorMessage;\n\n      const language = isDefined(jsonParsedErrorMessage) ? 'json' : 'plaintext';","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts#L109-L145","documentation":"The message shown is the literal expression thrown at useTestHttpRequest.ts:127: the testHttpRequest mutation returned `success: false` and this Error's message is the server's `error` payload (stringified if it is not already a string). It represents a real failure of the outbound HTTP call the workflow step was testing.","triggerScenarios":"The target URL of the workflow HTTP request action is unreachable, returns a non-2xx status, has invalid/TLS problems, or rejects the request (auth, headers, body). The server wraps that upstream failure into `response.error` and the client re-throws it.","commonSituations":"Testing a workflow HTTP step against a URL that is down, requires authentication not supplied, blocks the server's egress IP, has an invalid/expired TLS cert, or returns 4xx/5xx. Body template substitution produced invalid JSON.","solutions":["Read the thrown message: for non-string errors it is JSON-stringified, so parse it to find status/url/detail.","Re-run the same URL/headers/body with curl from the server's network to reproduce the upstream failure.","Correct the URL, add the missing Authorization header, or fix the body template so substituted output is valid."],"exampleFix":"// the thrown message is the upstream error; surface it to the user\n// before: throw new Error(isString(response.error) ? response.error : JSON.stringify(response.error));\n// after:  const upstream = isString(response.error) ? response.error : JSON.stringify(response.error, null, 2);\n//         throw new Error(`HTTP request failed: ${upstream}`);","handlingStrategy":"try-catch","validationCode":"const assertUpstreamSuccess = (resp: { success: boolean; error?: unknown }) => {\n  if (resp.success !== true) {\n    throw new Error(isString(resp.error) ? resp.error : JSON.stringify(resp.error));\n  }\n};","typeGuard":"const isHttpTestSuccess = (r: unknown): r is { success: true; result: unknown } =>\n  typeof r === 'object' && r !== null && (r as any).success === true;","tryCatchPattern":"// the hook already catches and surfaces errorMessage via httpRequestTestData.\n// Consume that state rather than re-throwing:\nif (httpRequestTestData.output?.error) {\n  showTestError(httpRequestTestData.output.error);\n}","preventionTips":["Before testing, run the same URL/headers/body from the server network with curl to isolate egress issues.","Validate substituted URL is a well-formed absolute URL and body (when JSON) parses.","Make sure authorization headers are populated when the target requires auth."],"tags":["workflow","http-request","network","graphql"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}