jackwener/OpenCLI · error · CommandExecutionError

exception

Error message

exception

What it means

Any exception thrown inside the in-page whoami IIFE is caught and returned as {kind:'exception', detail}, which verifyLinuxDoIdentity rethrows as CommandExecutionError `Linux.do whoami failed: <detail>`. This wraps browser-side failures of the probe itself — network errors on fetch, JSON parse errors, DOM access problems.

Source

Thrown at clis/linux-do/auth.js:37

      const r = await fetch('/u/' + encodeURIComponent(u) + '.json', {
        credentials: 'include',
        headers: { Accept: 'application/json' },
      });
      if (r.status === 401 || r.status === 403) {
        return { kind: 'auth', detail: 'Linux.do /u/<self>.json HTTP ' + r.status };
      }
      if (!r.ok) return { kind: 'http', httpStatus: r.status };
      const d = await r.json();
      const user = d?.user;
      if (!user || !user.id) return { kind: 'auth', detail: 'Linux.do /u/<self>.json missing user.id' };
      return { ok: true, user_id: String(user.id), username: String(user.username || u), name: String(user.name || '') };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('linux.do', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Linux.do /u/<self>.json`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Linux.do whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Linux.do probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, username: probe.username, name: probe.name };
}

registerSiteAuthCommands({
  site: 'linux-do',
  domain: 'linux.do',
  loginUrl: 'https://linux.do/login',
  columns: ['user_id', 'username', 'name'],
  quickCheck: hasLinuxDoSessionCookie,
  verify: verifyLinuxDoIdentity,
  poll: async (page) => {
    if (!await hasLinuxDoSessionCookie(page)) {
      throw new AuthRequiredError('linux.do', 'Waiting for Linux.do _t cookie');
    }
    return verifyLinuxDoIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the detail suffix in the message to identify the underlying browser-side exception
  2. Ensure the browser stays on https://linux.do/ for the duration of verification and retry
  3. Verify network/proxy connectivity to linux.do from the automation browser
  4. If an HTML error page is being returned (json() throws), retry after the server recovers or re-login
Defensive patterns

Strategy: try-catch

Validate before calling

// Stay on linux.do and online before probing
const onSite = page.url().startsWith('https://linux.do');
if (!onSite || !navigator.onLine) throw new Error('Browser not ready for linux.do whoami');

Try / catch

try {
  const identity = await verifyLinuxDoIdentity(page);
} catch (e) {
  if (String(e.message).startsWith('Linux.do whoami failed')) {
    await page.goto('https://linux.do/'); await page.wait(3);
    return verifyLinuxDoIdentity(page); // retry once after re-navigation
  } else throw e;
}

Prevention

When it happens

Trigger: fetch('/u/<self>.json') rejecting (network failure, CORS/blocked), response.json() throwing on an HTML error body, navigation interrupted mid-probe, or page.evaluate context destroyed.

Common situations: Linux.do serving an HTML error page instead of JSON (so r.json() throws); browser navigated away during the probe; offline/proxy network issues; extension or CSP blocking the in-page fetch.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/e9a99be9d0c5279c. Report an issue: GitHub.