Kong/insomnia · error · TypeError
addQueryParams: invalid params
Error message
addQueryParams: invalid params: ${JSON.stringify(params)} What it means
Validation guard in Url.addQueryParams: the params argument is neither a string nor an array of param options/objects — it has an unrecognized type. The invalid value is JSON-stringified into the message for diagnosis.
Solutions
- Pass 'a=1&b=2' or an array of {key, value} objects
- Check the argument type in the calling script
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/urls.ts:276 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/f98852f15ebdb088.
Report an issue: GitHub.
Appendix: source
Thrown at packages/insomnia-scripting-environment/src/objects/urls.ts:276
return undefined;
}
addQueryParams(params: QueryParamOptions[] | string) {
if (typeof params === 'string') {
// URLSearchParams is not used here as it encodes content
const pairs = params.split('&');
pairs.forEach(pair => {
const parts = pair.split('=');
this.queryParams = [...this.queryParams, new QueryParam({ key: parts[0], value: parts[1] })];
// this.urlObject.searchParams.append(pair[0], pair[1]);
});
} else if (Array.isArray(params)) {
params.forEach(pair => {
this.queryParams = [...this.queryParams, new QueryParam({ ...pair })];
});
} else {
throw new TypeError(`addQueryParams: invalid params: ${JSON.stringify(params)}`);
}
}
getHost() {
if (this.urlObject) {
return this.urlObject.hostname;
}
return '';
}
getPath(_unresolved?: boolean) {
if (this.urlObject) {
return this.urlObject.pathname;
}
return '';
}
getPathWithQuery() {View on GitHub (pinned to d9bb2b0142)