{"record":{"id":"6bf3353c9f673f63","repo":"diegosouzapw/OmniRoute","slug":"invalid-session-cookie","errorCode":null,"errorMessage":"Invalid session cookie","messagePattern":"Invalid session cookie","errorType":"exception","errorClass":"SessionAuthError","httpStatus":401,"severity":"error","filePath":"open-sse/executors/chatgpt-web.ts","lineNumber":293,"sourceCode":"): Promise<TokenEntry> {\n  const cached = tokenLookup(cookie);\n  if (cached) return cached;\n\n  const headers: Record<string, string> = {\n    ...browserHeaders(),\n    Accept: \"application/json\",\n    Cookie: buildSessionCookieHeader(cookie),\n  };\n\n  const response = await tlsFetchChatGpt(SESSION_URL, {\n    method: \"GET\",\n    headers,\n    timeoutMs: 30_000,\n    signal,\n  });\n\n  if (response.status === 401 || response.status === 403) {\n    throw new SessionAuthError(\"Invalid session cookie\");\n  }\n  if (response.status >= 400) {\n    throw new Error(`Session exchange failed (HTTP ${response.status})`);\n  }\n\n  const refreshed = mergeRefreshedCookie(cookie, response.headers.get(\"set-cookie\"));\n  let data: SessionResponse = {};\n  try {\n    data = JSON.parse(response.text || \"{}\");\n  } catch {\n    console.warn(\"[chatgpt-web] session response JSON parse failed\");\n    /* empty body or non-JSON */\n  }\n  if (!data.accessToken) {\n    throw new SessionAuthError(\"Session response missing accessToken — cookie likely expired\");\n  }\n\n  const expiresAt = data.expires ? new Date(data.expires).getTime() : Date.now() + TOKEN_TTL_MS;","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/chatgpt-web.ts#L275-L311","documentation":"Typed auth failure (SessionAuthError) in the chatgpt-web session exchange: GET SESSION_URL with the stored session cookie returned 401 or 403. ChatGPT's backend rejected the credential outright — the cookie is expired, revoked, or was copied incorrectly; this error class signals the connection credential needs renewal rather than a retry.","triggerScenarios":"Thrown at open-sse/executors/chatgpt-web.ts:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log in to ChatGPT again and save a fresh __Secure-next-auth.session-token cookie on the connection","Verify the cookie was copied completely (it is long and easily truncated)","If the account required re-verification (captcha/logout), complete it in a browser before re-saving"],"exampleFix":null,"handlingStrategy":"retry","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"}