diegosouzapw/OmniRoute · error · SessionAuthError

Invalid session cookie

Error message

Invalid session cookie

What it means

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.

Solutions

  1. Log in to ChatGPT again and save a fresh __Secure-next-auth.session-token cookie on the connection
  2. Verify the cookie was copied completely (it is long and easily truncated)
  3. If the account required re-verification (captcha/logout), complete it in a browser before re-saving
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at open-sse/executors/chatgpt-web.ts:293 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/6bf3353c9f673f63. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/chatgpt-web.ts:293

): Promise<TokenEntry> {
  const cached = tokenLookup(cookie);
  if (cached) return cached;

  const headers: Record<string, string> = {
    ...browserHeaders(),
    Accept: "application/json",
    Cookie: buildSessionCookieHeader(cookie),
  };

  const response = await tlsFetchChatGpt(SESSION_URL, {
    method: "GET",
    headers,
    timeoutMs: 30_000,
    signal,
  });

  if (response.status === 401 || response.status === 403) {
    throw new SessionAuthError("Invalid session cookie");
  }
  if (response.status >= 400) {
    throw new Error(`Session exchange failed (HTTP ${response.status})`);
  }

  const refreshed = mergeRefreshedCookie(cookie, response.headers.get("set-cookie"));
  let data: SessionResponse = {};
  try {
    data = JSON.parse(response.text || "{}");
  } catch {
    console.warn("[chatgpt-web] session response JSON parse failed");
    /* empty body or non-JSON */
  }
  if (!data.accessToken) {
    throw new SessionAuthError("Session response missing accessToken — cookie likely expired");
  }

  const expiresAt = data.expires ? new Date(data.expires).getTime() : Date.now() + TOKEN_TTL_MS;

View on GitHub (pinned to a179ffed5b)