Kong/insomnia · error · TypeError

removeQueryParams: failed to remove query params: unknown…

Error message

removeQueryParams: failed to remove query params: unknown params type, only supports QueryParam[], string[] or string

What it means

Type guard at the end of Url.removeQueryParams: the params argument is not a QueryParam[], string[], or plain string (the three supported forms), so the removal filter cannot be built and the call is rejected.

Solutions

  1. Pass a param key string, string[] of keys, or QueryParam[]
  2. Avoid null/undefined and object literals as arguments
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/urls.ts:330 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/76e4a53969e315d0. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-scripting-environment/src/objects/urls.ts:330

    return '';
  }

  removeQueryParams(params: QueryParam[] | string[] | string) {
    if (typeof params === 'string') {
      this.queryParams = this.queryParams.filter(param => param.key !== params);
    } else if (Array.isArray(params)) {
      this.queryParams = this.queryParams.filter(param => {
        const shouldDelete = params.some(paramToRemove => {
          if (typeof paramToRemove === 'string') {
            return param.key === paramToRemove;
          }
          return param.key === paramToRemove.key;
        });

        return !shouldDelete;
      });
    } else {
      throw new TypeError(
        'removeQueryParams: failed to remove query params: unknown params type, only supports QueryParam[], string[] or string',
      );
    }
  }

  override toString(_forceProtocol?: boolean) {
    if (this.urlObject) {
      const newUrlObject = new URL(this.urlObject.toString());
      newUrlObject.search = this.getQueryString();
      const urlInString = newUrlObject.toString();
      if (this.urlObject.pathname === '/' && urlInString === this.origin + '/') {
        // try to avoid replacing empty path with '/'
        return urlInString.slice(0, -1);
      }
      return urlInString;
    }
    return this.origin || '';
  }

View on GitHub (pinned to d9bb2b0142)