jackwener/OpenCLI · error · CommandExecutionError
HTTP ${result.httpStatus} from /api/auth/session
Error message
HTTP ${result.httpStatus} from /api/auth/session What it means
verifyGrokIdentity() throws CommandExecutionError(`HTTP <status> from /api/auth/session`) when the in-page probe gets a non-OK response from Grok's NextAuth session endpoint that is not an auth status (i.e. anything other than 200/401/403 — e.g. 429, 5xx, 502/503). This is not a login problem: the session endpoint itself failed or is rate-limiting/throttling, so the identity check cannot complete. It is distinguished from AuthRequiredError precisely so users do not needlessly re-login.
Source
Thrown at clis/grok/auth.js:33
const result = await page.evaluate(`(async () => {
try {
const res = await fetch('/api/auth/session', { credentials: 'include', headers: { 'Accept': 'application/json' } });
if (res.status === 401 || res.status === 403) {
return { kind: 'auth', detail: 'Grok /api/auth/session HTTP ' + res.status };
}
if (!res.ok) return { kind: 'http', httpStatus: res.status };
const d = await res.json();
const user = d && d.user;
if (!user || !user.id) {
return { kind: 'auth', detail: 'Grok /api/auth/session has no user — anonymous' };
}
return { ok: true, user_id: String(user.id), name: String(user.name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') throw new AuthRequiredError('grok.com', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/auth/session`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Grok whoami failed: ${result.detail}`);
if (!result?.ok) throw new CommandExecutionError(`Unexpected Grok probe: ${JSON.stringify(result)}`);
return { user_id: result.user_id, name: result.name };
}
registerSiteAuthCommands({
site: 'grok',
domain: 'grok.com',
loginUrl: 'https://grok.com/auth/sign-in',
columns: ['user_id', 'name'],
quickCheck: hasGrokSessionCookie,
verify: verifyGrokIdentity,
poll: async (page) => {
if (!await hasGrokSessionCookie(page)) {
throw new AuthRequiredError('grok.com', 'Waiting for Grok session cookie');
}
return verifyGrokIdentity(page);
},View on GitHub (pinned to 49907e53dc)
Solutions
- Wait briefly and retry the verify/whoami command — 429/5xx are usually transient; back off exponentially if rate-limited.
- Check grok.com status in a normal browser (or status page) to see if it's an outage before troubleshooting locally.
- If 429, reduce request frequency / avoid running multiple grok commands concurrently from the same IP.
- If 5xx persist, try a different network/IP to rule out edge or proxy-level blocking.
- Do NOT re-login for this error — the session cookie is not the problem; re-auth will not fix a server-side failure.
Example fix
// before: immediate verify during an outage
const who = await grokWhoami(); // CommandExecutionError: HTTP 503 from /api/auth/session
// after: retry with backoff
async function whoamiWithRetry() {
for (let attempt = 0; attempt < 4; attempt++) {
try { return await grokWhoami(); }
catch (e) {
if (!/HTTP \d+ from \/api\/auth\/session/.test(e.message) || attempt === 3) throw e;
await new Promise(r => setTimeout(r, 2 ** attempt * 2000));
}
}
} Defensive patterns
Strategy: retry
Try / catch
try {
const who = await run('grok', 'whoami');
} catch (e) {
const m = /HTTP (\d{3}) from \/api\/auth\/session/.exec(e.message ?? '');
if (m && Number(m[1]) !== 401 && Number(m[1]) !== 403) {
// server-side issue: back off and retry, do NOT re-login
await new Promise(r => setTimeout(r, 5000));
return await run('grok', 'whoami');
}
throw e;
} Prevention
- Add exponential-backoff retries around grok verify/whoami calls for 429/5xx statuses.
- Serialize grok commands instead of running many concurrently from one IP.
- Check grok.com availability (browser or status page) before blaming local configuration.
- Distinguish HTTP-status errors from AuthRequiredError — only the latter warrants re-login.
- Route automated traffic through a stable, non-throttled network path.
When it happens
Trigger: Running the grok auth verify/whoami flow when the fetch('/api/auth/session') inside page.evaluate returns a status like 429 (rate limited), 500/502/503/504 (server error), or any other non-OK, non-401/403 code — e.g. grok.com is having an outage, is throttling the IP, or a gateway/CDN in front of it errors.
Common situations: grok.com server-side incident or maintenance window; IP-level rate limiting after many automated requests; CDN/proxy (Cloudflare) 5xx responses; transient network errors at the edge during peak load; retry storms from multiple concurrent CLI runs hammering the endpoint.
Related errors
- Ctrip flight API returned HTTP ${status || 'unknown'}
- autohome ${contextHint} HTTP ${resp.status}
- dongchedi ${contextHint} HTTP ${resp.status}
- eastmoney convertible failed: HTTP ${resp.status}
- HTTP_ERROR
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1caaa1bcd0258ca5.
Report an issue: GitHub.