diegosouzapw/OmniRoute · error · Error
Invalid cookie JSON at index
Error message
Invalid cookie JSON at index ${i}: missing required field 'value' What it means
Validation guard in parseJsonCookiesToHeader(): the cookie array element at the given index has a 'name' but its 'value' field is not a string (missing, null, or a number/boolean/object). Every entry must have a string value to build the Cookie header.
Solutions
- Set a string 'value' field on the cookie entry at the reported index.
- If the value was exported as a non-string JSON type, convert it to a string before saving.
- Re-export cookies from the browser in the documented [{name, value}] JSON format.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/providers/webCookieAuth.ts:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/2d4db4335a74def2.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/providers/webCookieAuth.ts:54
return null;
}
if (!Array.isArray(parsed)) return null;
if (parsed.length === 0) return "";
const parts: string[] = [];
for (let i = 0; i < parsed.length; i++) {
const entry = parsed[i];
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
throw new Error(`Invalid cookie JSON at index ${i}: expected an object`);
}
const record = entry as Record<string, unknown>;
if (typeof record.name !== "string" || !record.name) {
throw new Error(`Invalid cookie JSON at index ${i}: missing required field 'name'`);
}
if (typeof record.value !== "string") {
throw new Error(`Invalid cookie JSON at index ${i}: missing required field 'value'`);
}
parts.push(`${record.name}=${record.value}`);
}
return parts.join("; ");
}
export function normalizeSessionCookieHeader(rawValue: string, defaultCookieName: string): string {
const stripped = stripCookieInputPrefix(rawValue);
if (!stripped) return "";
const jsonResult = parseJsonCookiesToHeader(stripped);
if (jsonResult !== null) {
return jsonResult;
}
if (stripped.includes("=")) {View on GitHub (pinned to a179ffed5b)