jackwener/OpenCLI · error · CommandExecutionError
whoami failed: ${result.detail}
Error message
whoami failed: ${result.detail} What it means
This CommandExecutionError is thrown when the reddit whoami script's result has kind === 'exception', meaning the in-page/in-process whoami evaluation itself threw an exception; result.detail carries the underlying error message. The CLI re-raises it as 'whoami failed: <detail>' so the original failure detail is preserved in the command error. It indicates a client-side execution failure of the whoami routine, not an HTTP status problem or missing auth.
Source
Thrown at clis/reddit/whoami.js:52
const d = await res.json();
const me = d?.data;
if (!me?.name) {
return { kind: 'auth', detail: 'Not logged in to reddit.com (no identity in /api/me.json)' };
}
return { kind: 'ok', identity: me };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') {
throw new AuthRequiredError('reddit.com', result.detail);
}
if (result?.kind === 'http') {
throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);
}
if (result?.kind === 'exception') {
throw new CommandExecutionError(`whoami failed: ${result.detail}`);
}
if (result?.kind !== 'ok') {
throw new CommandExecutionError(`Unexpected result from reddit whoami: ${JSON.stringify(result)}`);
}
const u = result.identity;
const created = u.created_utc
? new Date(u.created_utc * 1000).toISOString().split('T')[0]
: null;
const linkKarma = typeof u.link_karma === 'number' ? u.link_karma : null;
const commentKarma = typeof u.comment_karma === 'number' ? u.comment_karma : null;
const totalKarma = typeof u.total_karma === 'number'
? u.total_karma
: (linkKarma != null && commentKarma != null ? linkKarma + commentKarma : null);
const inboxCount = typeof u.inbox_count === 'number' ? u.inbox_count : null;
return [
{ field: 'Username', value: 'u/' + u.name },View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect result.detail (the text after 'whoami failed:') to find the original exception and fix its root cause.
- Re-run the command once; transient page/context crashes often resolve on a fresh attempt.
- If detail shows a script/TypeError, check whether reddit.com markup changed and update the whoami extraction script.
- Update the CLI/automation stack (browser, driver, this library) to versions compatible with the current Reddit DOM.
- Catch CommandExecutionError and log the full detail before deciding whether to retry or re-authenticate.
Example fix
// before: treating all failures as auth and retrying login
try { await whoami(); } catch { await login(); }
// after: branch on the failure detail
try {
await whoami();
} catch (e) {
if (e instanceof AuthRequiredError) await login();
else throw e; // 'whoami failed: ...' is not fixable by re-login
} Defensive patterns
Strategy: try-catch
Type guard
function isWhoamiExceptionError(e) {
return e instanceof CommandExecutionError && e.message.startsWith('whoami failed: ');
} Try / catch
try {
await whoami();
} catch (e) {
if (isWhoamiExceptionError(e)) {
console.error('whoami runtime failure:', e.message.slice('whoami failed: '.length));
// one retry after fresh page/context, then give up
} else throw e;
} Prevention
- Keep the automation browser/page alive for the duration of the command.
- Keep the CLI and embedded scripts version-aligned so the extraction logic matches current site markup.
- Log result.detail immediately — it contains the original exception text.
- Retry once on a fresh page before escalating; many failures are transient context crashes.
When it happens
Trigger: Calling the reddit whoami command when the embedded evaluation throws: e.g., DOM/page context unavailable, a script error inside the whoami snippet, or an unexpected runtime exception captured by the wrapper and returned as { kind: 'exception', detail }.
Common situations: Browser/page crashed or navigated mid-eval so the script context is gone; site markup changes causing the extraction script to throw a TypeError (reading property of undefined); automation driver version mismatch causing evaluate() to fail; timeouts propagating as exceptions inside the probe.
Related errors
- HTTP ${result.httpStatus} from ${result.where}
- Unexpected result from reddit whoami: ${JSON.stringify(resul
- Not a git repository
- Working tree not clean: ${status}
- Stale .git/index.lock found — remove it first
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3e7741cf1746823b.
Report an issue: GitHub.