jackwener/OpenCLI · error · CommandExecutionError

Unexpected Gemini probe: ${JSON.stringify(probe)}

Error message

Unexpected Gemini probe: ${JSON.stringify(probe)}

What it means

A CommandExecutionError thrown when the in-page identity probe returns neither ok:true nor kind:'auth' — an unexpected/undefined probe result. This guards against silent failures of the page.evaluate bridge (e.g. null result, selector not found path not returning kind:'auth').

Source

Thrown at clis/gemini/auth.js:31

  }
  await page.goto('https://gemini.google.com/app');
  await page.wait(3);
  const probe = await page.evaluate(`
    (() => {
      const a = document.querySelector('a[aria-label^="Google Account:"]');
      if (!a) {
        return { kind: 'auth', detail: 'Gemini account link missing — not signed into Google' };
      }
      const label = a.getAttribute('aria-label') || '';
      const m = label.match(/Google Account:\\s*([^(]+?)\\s*\\(([^)]+)\\)/);
      if (!m) {
        return { kind: 'auth', detail: 'Gemini aria-label unparseable: ' + label };
      }
      return { ok: true, name: m[1].trim() };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('gemini.google.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);
  return { name: probe.name };
}

registerSiteAuthCommands({
  site: 'gemini',
  domain: 'gemini.google.com',
  loginUrl: 'https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fgemini.google.com%2F',
  columns: ['name'],
  quickCheck: hasGoogleSessionCookie,
  verify: verifyGeminiIdentity,
  poll: async (page) => {
    if (!await hasGoogleSessionCookie(page)) {
      throw new AuthRequiredError('gemini.google.com', 'Waiting for Google session cookies');
    }
    return verifyGeminiIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run `opencli gemini login` and retry the command
  2. Inspect the automation browser's gemini.google.com/app DOM for `a[aria-label^="Google Account:"]` and update the probe in clis/gemini/auth.js
  3. Check the browser bridge is healthy (no CDP disconnects) and re-run
  4. Log the raw probe value at auth.js:31 to see the actual unexpected shape before fixing

Example fix

// before
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);
// after
if (!probe) throw new AuthRequiredError('gemini.google.com', 'Probe returned no result — session likely missing');
if (!probe.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);
Defensive patterns

Strategy: type-guard

Validate before calling

const probe = await page.evaluate(probeScript);
if (!probe || typeof probe !== 'object') {
  throw new AuthRequiredError('gemini.google.com', 'No probe result — session missing');
}

Type guard

function isWellFormedProbe(p) {
  return !!p && typeof p === 'object' &&
    (p.ok === true || (p.kind === 'auth' && typeof p.detail === 'string'));
}

Try / catch

try {
  const identity = await getGeminiIdentity();
} catch (e) {
  if (/Unexpected Gemini probe/.test(e.message)) {
    // inspect e.message JSON, then re-login or update the probe script
  } else throw e;
}

Prevention

When it happens

Trigger: `probe` is null/undefined or an object without ok/kind flags after `page.evaluate(...)` in verifyGeminiIdentity (auth.js:31).

Common situations: No Google Account anchor found AND probe returned undefined (selector path missing); browser bridge failed to serialize the evaluate result; Gemini DOM restructured so the probe's return shape changed.

Related errors


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