Kong/insomnia · error · Error

the request type must be: string | Request | RequestOptions.

Error message

the request type must be: string | Request | RequestOptions.

What it means

Type guard at the end of requestToCurlOptions in send-request: the pre-request sendRequest() argument is not a URL string, a Request object, or a RequestOptions object, so the curl invocation cannot be built.

Solutions

  1. Pass a URL string, insomnia.sendRequest's Request instance, or a plain options object
  2. Check for undefined arguments in the script's sendRequest call
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/send-request.ts:195 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/2362449de8709e16. Report an issue: GitHub.

Appendix: source

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

              // unused fields because they are not persisted
              disabled: false,
              isPrivate: false,
              _id: '',
              type: '',
              parentId: '',
              modified: 0,
              created: 0,
              name: '',
            },
          ]
        : [],
      caCertficatePath: null, // the request in pre-request script doesn't support customizing ca yet
      socketPath: undefined,
      authHeader: undefined, // TODO: add this for bearer and other auth methods
    };
  }

  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');
  }

View on GitHub (pinned to d9bb2b0142)