{"record":{"id":"54ea9710a7705c43","repo":"Kong/insomnia","slug":"curloutputtoresponse-the-lastredirect-is-not-defi","errorCode":null,"errorMessage":"curlOutputToResponse: the lastRedirect is not defined","messagePattern":"curlOutputToResponse: the lastRedirect is not defined","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/insomnia-scripting-environment/src/objects/send-request.ts","lineNumber":211,"sourceCode":"  }\n\n  throw new Error('the request type must be: string | Request | RequestOptions.');\n}\n\nasync function curlOutputToResponse(\n  result: CurlRequestOutput,\n  request: string | Request | RequestOptions,\n): Promise<Response> {\n  if (result.headerResults.length === 0) {\n    throw new Error('curlOutputToResponse: no header result is found');\n  }\n  if (result.patch.error) {\n    throw result.patch.error;\n  }\n\n  const lastRedirect = result.headerResults[result.headerResults.length - 1];\n  if (!lastRedirect) {\n    throw new Error('curlOutputToResponse: the lastRedirect is not defined');\n  }\n\n  const originalRequest =\n    typeof request === 'string'\n      ? new Request({ url: request, method: 'GET' })\n      : request instanceof Request\n        ? request\n        : new Request(request);\n\n  const headers = lastRedirect.headers.map((header: { name: string; value: string }) => ({\n    key: header.name,\n    value: header.value,\n  }));\n\n  const cookieHeaders = lastRedirect.headers.filter(header => {\n    return header.name.toLowerCase() === 'set-cookie';\n  });\n  // TODO: tackle stream field but currently it is just a duplication of body","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia-scripting-environment/src/objects/send-request.ts#L193-L229","documentation":"Error \"curlOutputToResponse: the lastRedirect is not defined\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia-scripting-environment/src/objects/send-request.ts:211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}