diegosouzapw/OmniRoute · error · SessionAuthError

Session response missing accessToken — cookie likely expired

Error message

Session response missing accessToken — cookie likely expired

What it means

Response-shape auth failure (SessionAuthError) after a 2xx session exchange: the JSON body (possibly parsed as empty after a parse failure) contains no accessToken. The session cookie authenticated but ChatGPT did not issue a bearer token — almost always an expired/dying session; the credential must be refreshed, not retried.

Solutions

  1. Refresh the session cookie by logging in to ChatGPT and re-saving it on the connection
  2. Confirm the account is not stuck in a pending-verification state in a browser
  3. If the JSON parse warning fired, capture the raw (sanitized) body to check for a Cloudflare interstitial
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

  });

  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;
  const entry: TokenEntry = {
    accessToken: data.accessToken,
    accountId: data.user?.id ?? null,
    expiresAt: Math.min(expiresAt, Date.now() + TOKEN_TTL_MS),
    refreshedCookie: refreshed ?? undefined,
  };
  tokenStore(cookie, entry);
  return entry;
}

class SessionAuthError extends Error {
  constructor(message: string) {
    super(message);
    this.name = "SessionAuthError";
  }

View on GitHub (pinned to a179ffed5b)