Kong/insomnia · error · Error
failed to parse cookie, the cookie string seems invalid
Error message
failed to parse cookie, the cookie string seems invalid
What it means
Cookie constructor guard: the argument was a string, but tough-cookie's Cookie.parse returned null, meaning the string is not a syntactically valid Set-Cookie/Cookie serialisation (bad name=value syntax, illegal characters, or malformed attributes).
Solutions
- Pass a valid cookie string like 'name=value; Path=/'
- Pass a CookieOptions object instead of a raw string
- Sanitize input before constructing cookies in scripts
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/cookies.ts:42 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26).
Data as JSON: /api/errors/e3eeb27d398ef9f4.
Report an issue: GitHub.
Appendix: source
Thrown at packages/insomnia-scripting-environment/src/objects/cookies.ts:42
httpOnly?: boolean;
hostOnly?: boolean;
session?: boolean;
extensions?: { key: string; value: string }[];
}
export class Cookie extends Property {
override readonly _kind: string = 'Cookie';
protected cookie: ToughCookie;
private extensions?: { key: string; value: string }[];
private insoExtensions: InsomniaCookieExtensions = {};
constructor(cookieDef: CookieOptions | string) {
super();
if (typeof cookieDef === 'string') {
const cookieDefParsed = Cookie.parse(cookieDef);
if (!cookieDefParsed) {
throw new Error('failed to parse cookie, the cookie string seems invalid');
}
cookieDef = cookieDefParsed;
}
const def = { ...cookieDef };
this.extensions = def.extensions ? [...def.extensions] : [];
def.extensions = [];
const cookie = ToughCookie.fromJSON(def);
if (!cookie) {
throw new Error('failed to parse cookie, the cookie string seems invalid');
}
this.id = cookieDef.id || '';
this.cookie = cookie;
this.insoExtensions = {
creation: cookieDef.creation,
creationIndex: cookieDef.creationIndex,View on GitHub (pinned to d9bb2b0142)