jackwener/OpenCLI · error · CommandExecutionError

Unexpected Linux.do probe: ${JSON.stringify(probe)}

Error message

Unexpected Linux.do probe: ${JSON.stringify(probe)}

What it means

verifyLinuxDoIdentity probes the signed-in linux.do session by evaluating a fetch of /u/<self>.json in the browser page and classifying the result by `kind`. Auth, HTTP, and exception outcomes have dedicated error branches; this final fallback CommandExecutionError fires only when the probe resolves to an unrecognized shape — i.e. `probe` is null/undefined, or an object without `ok: true` and without any known `kind`. The library throws it because a structurally unexpected probe result means the page environment (evaluate serialization, site JS) behaved in an unanticipated way.

Source

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

        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. Close and relaunch the browser session, then retry `opencli linux-do login`/verify — a transient page-context crash is the most common cause of a null probe.
  2. Ensure no navigation runs concurrently with verification; verify only after page.goto('https://linux.do/') + page.wait(2) completes (already done by verifyLinuxDoIdentity — remove custom callers that navigate during poll).
  3. Check the JSON payload in the message: it shows the actual probe; if it's an object with an unknown kind, update the CLI or site probe to the current linux.do behavior.
  4. Re-run with a fresh browser profile to rule out extensions or cached service workers interfering with in-page fetch.

Example fix

// before (custom poller navigating during verify)
await page.goto('https://linux.do/latest');
const identity = await verifyLinuxDoIdentity(page);
// after (let verifyLinuxDoIdentity own navigation)
await page.waitForLoadState('networkidle');
const identity = await verifyLinuxDoIdentity(page);
Defensive patterns

Strategy: try-catch

Validate before calling

// before verifying, confirm the page and session are usable
if (!page) throw new Error('Browser page required before linux.do verify');
const cookies = await page.getCookies({ url: 'https://linux.do' });
if (!cookies.some(c => c.name === '_t' && c.value)) {
  throw new Error('Not signed in to linux.do: _t cookie missing');
}

Type guard

function isKnownProbe(p) {
  return !!p && typeof p === 'object' &&
    (p.ok === true || ['auth', 'http', 'exception'].includes(p.kind));
}

Try / catch

try {
  const identity = await verifyLinuxDoIdentity(page);
} catch (err) {
  if (/Unexpected Linux\.do probe/.test(err.message)) {
    // probe came back null/unrecognized: reopen the page and retry once
    page = await browser.newPage();
    await page.goto('https://linux.do');
    return verifyLinuxDoIdentity(page);
  }
  if (err instanceof AuthRequiredError) return promptLogin();
  throw err;
}

Prevention

When it happens

Trigger: 1) `page.evaluate` returns null/undefined (page navigated away mid-evaluate, context destroyed, or evaluate serialization failure) so `probe?.ok` and `probe?.kind` are both falsy. 2) The in-page IIFE is modified/monkey-patched or the browser blocks `fetch` in a way that neither throws nor returns a known kind. 3) A linux.do site change makes the probe object shape drift from {kind|ok}. Since the IIFE always returns a tagged object, in practice this is almost always probe === null/undefined from a broken evaluate context.

Common situations: Browser automation page crashed or was closed during login polling; the linux.do tab navigated (e.g. redirect during page.goto + page.wait(2)) before evaluate returned; running against a mocked/fake page object in tests that doesn't return the expected tagged probe; older browser or extension interfering with fetch inside evaluate.

Related errors


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