{"record":{"id":"240b082041c0d051","repo":"diegosouzapw/OmniRoute","slug":"chatgpt-cookie-header-is-missing-secure-next-aut","errorCode":null,"errorMessage":"ChatGPT Cookie header is missing __Secure-next-auth.session-token","messagePattern":"ChatGPT Cookie header is missing __Secure-next-auth\\.session-token","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/executors/chatgpt-web-codex/storageState.ts","lineNumber":37,"sourceCode":"  };\n}\n\nfunction cookieHeaderValue(raw: string): string {\n  return raw.trim().replace(/^cookie\\s*:\\s*/i, \"\");\n}\n\nfunction parseCookies(raw: string): Array<Record<string, unknown>> {\n  const header = cookieHeaderValue(raw);\n  const pairs = header\n    .split(/;\\s*/)\n    .map((part) => {\n      const separator = part.indexOf(\"=\");\n      return separator > 0 ? [part.slice(0, separator).trim(), part.slice(separator + 1)] : null;\n    })\n    .filter((pair): pair is [string, string] => Boolean(pair?.[0]));\n  if (!pairs.some(([name]) => /^__Secure-next-auth\\.session-token(?:\\.\\d+)?$/.test(name))) {\n    if (header.includes(\";\") || header.includes(\"=\")) {\n      throw new Error(\"ChatGPT Cookie header is missing __Secure-next-auth.session-token\");\n    }\n    pairs.push([\"__Secure-next-auth.session-token\", header]);\n  }\n  return pairs.map(([name, value]) => ({\n    name,\n    value,\n    domain: \".chatgpt.com\",\n    path: \"/\",\n    secure: true,\n    httpOnly: name.startsWith(\"__Secure-\") || name.startsWith(\"__Host-\"),\n    sameSite: \"Lax\",\n  }));\n}\n\nfunction cookieFingerprint(raw: string): string {\n  return createHash(\"sha256\").update(cookieHeaderValue(raw)).digest(\"hex\");\n}\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/chatgpt-web-codex/storageState.ts#L19-L55","documentation":"Cookie parsing guard in parseCookies (storageState.ts): the supplied cookie header contains no __Secure-next-auth.session-token (with optional numeric suffix) pair. That token is the only credential the ChatGPT Web flow accepts, so a header without it — wrong cookie copied, wrong site's cookies, or a truncated paste — cannot bootstrap the storage state.","triggerScenarios":"Thrown at open-sse/executors/chatgpt-web-codex/storageState.ts:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Copy the full Cookie header from an authenticated chat.openai.com session and re-save it","Make sure the __Secure-next-auth.session-token cookie is included (not just cf_clearance or other cookies)","Re-login to ChatGPT if the dev-tools cookie set no longer contains the session token"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}