jackwener/OpenCLI · error · CommandExecutionError
HTTP ${result.httpStatus} from /api/organizations
Error message
HTTP ${result.httpStatus} from /api/organizations What it means
This CommandExecutionError is thrown by verifyClaudeIdentity when the in-page fetch to https://claude.ai/api/organizations returns a non-OK, non-401/403 status (result.kind === 'http'). The library probes this endpoint after confirming a sessionKey cookie exists, to resolve the user's org identity; any other HTTP failure status (e.g. 429, 5xx) surfaces here. It means the Claude session cookie was present but the API call itself failed.
Source
Thrown at clis/claude/auth.js:35
const res = await fetch('/api/organizations', { credentials: 'include' });
if (res.status === 401 || res.status === 403) {
return { kind: 'auth', detail: 'Claude /api/organizations HTTP ' + res.status };
}
if (!res.ok) return { kind: 'http', httpStatus: res.status };
const d = await res.json();
if (!Array.isArray(d) || d.length === 0) {
return { kind: 'auth', detail: 'Claude /api/organizations empty' };
}
const userIdCookie = (document.cookie.split('; ').find(c => c.startsWith('ajs_user_id=')) || '').split('=')[1] || '';
const activeOrgCookie = (document.cookie.split('; ').find(c => c.startsWith('lastActiveOrg=')) || '').split('=')[1] || '';
const activeOrg = d.find(o => o.uuid === activeOrgCookie) || d[0];
return { ok: true, user_id: userIdCookie, org_name: activeOrg.name || '', org_uuid: activeOrg.uuid || '' };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') throw new AuthRequiredError('claude.ai', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/organizations`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Claude whoami failed: ${result.detail}`);
if (!result?.ok) throw new CommandExecutionError(`Unexpected Claude probe: ${JSON.stringify(result)}`);
if (!result.user_id) throw new AuthRequiredError('claude.ai', 'Claude session incomplete — ajs_user_id cookie missing');
return { user_id: String(result.user_id), org_name: String(result.org_name), org_uuid: String(result.org_uuid) };
}
registerSiteAuthCommands({
site: 'claude',
domain: 'claude.ai',
loginUrl: 'https://claude.ai/login',
columns: ['user_id', 'org_name', 'org_uuid'],
quickCheck: hasClaudeSessionCookie,
verify: verifyClaudeIdentity,
poll: async (page) => {
if (!await hasClaudeSessionCookie(page)) {
throw new AuthRequiredError('claude.ai', 'Waiting for Claude sessionKey cookie');
}
return verifyClaudeIdentity(page);View on GitHub (pinned to 49907e53dc)
Solutions
- Wait 30-60 seconds and re-run the command — most 429/5xx statuses are transient
- Re-run `opencli claude auth` (or the site auth flow) to refresh the session and re-probe
- Check https://claude.ai loads normally in the browser to rule out a Claude outage or account billing issue
- Clear claude.ai cookies, log in fresh, and retry so a stale/corrupt session is not causing odd responses
- Update the library in case Claude changed the endpoint and a newer version probes a different URL
Example fix
// before opencli claude whoami // -> HTTP 429 from /api/organizations // after sleep 60 && opencli claude whoami // retry after rate-limit window passes
Defensive patterns
Strategy: retry
Validate before calling
// pre-check session health before relying on whoami
const cookies = await page.getCookies({ url: 'https://claude.ai' });
if (!cookies.some(c => c.name === 'sessionKey' && c.value)) {
throw new Error('Run `opencli claude auth` first — no sessionKey cookie');
} Type guard
function isHttpFailure(result) {
return result && result.kind === 'http' && Number.isInteger(result.httpStatus) && !(result.httpStatus >= 200 && result.httpStatus < 400);
} Try / catch
try {
const identity = await verifyClaudeIdentity(page);
} catch (e) {
if (/HTTP \d+ from \/api\/organizations/.test(e.message)) {
await sleep(60000); // back off for rate limits / 5xx
return verifyClaudeIdentity(page);
}
throw e;
} Prevention
- Retry with backoff on 429/5xx instead of failing immediately
- Check https://status.anthropic.com or claude.ai availability before batch runs
- Refresh the session via `opencli claude auth` if errors persist across retries
- Keep the library updated in case Claude changes the probe endpoint
When it happens
Trigger: The sessionKey cookie exists but the /api/organizations request returns a status other than 200/401/403 — e.g. HTTP 429 rate limiting, 402 (billing/quota), 500/502/503 server errors, or 404 if Claude changes the endpoint path.
Common situations: Hitting Claude's API rate limits after repeated probes; transient Cloudflare or backend outages on claude.ai; Claude API returning an unusual status (e.g. 402 for disabled accounts); corporate proxies intercepting requests; Claude renaming/moving the /api/organizations endpoint in a frontend update.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- ${label} returned HTTP ${resp.status}: ${summarizeApiError(p
- ${label} returned HTTP ${res.status}
- HTTP_ERROR
- HTTP_ERROR
- HTTP_ERROR
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a5c4660da9e6ad4d.
Report an issue: GitHub.