Kong/insomnia · error · Error

curlOutputToResponse: the lastRedirect is not defined

Error message

curlOutputToResponse: the lastRedirect is not defined

What it means

Defensive guard in curlOutputToResponse: the last entry of the header results (the final redirect hop used to build the Response) is unexpectedly undefined after earlier checks passed, indicating malformed curl execution output.

Solutions

  1. Retry the request
  2. Inspect the raw curl output for malformed headers
  3. Report as a bug if it reproduces consistently
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/send-request.ts:211 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/54ea9710a7705c43. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-scripting-environment/src/objects/send-request.ts:211

  }

  throw new Error('the request type must be: string | Request | RequestOptions.');
}

async function curlOutputToResponse(
  result: CurlRequestOutput,
  request: string | Request | RequestOptions,
): Promise<Response> {
  if (result.headerResults.length === 0) {
    throw new Error('curlOutputToResponse: no header result is found');
  }
  if (result.patch.error) {
    throw result.patch.error;
  }

  const lastRedirect = result.headerResults[result.headerResults.length - 1];
  if (!lastRedirect) {
    throw new Error('curlOutputToResponse: the lastRedirect is not defined');
  }

  const originalRequest =
    typeof request === 'string'
      ? new Request({ url: request, method: 'GET' })
      : request instanceof Request
        ? request
        : new Request(request);

  const headers = lastRedirect.headers.map((header: { name: string; value: string }) => ({
    key: header.name,
    value: header.value,
  }));

  const cookieHeaders = lastRedirect.headers.filter(header => {
    return header.name.toLowerCase() === 'set-cookie';
  });
  // TODO: tackle stream field but currently it is just a duplication of body

View on GitHub (pinned to d9bb2b0142)