jackwener/OpenCLI · error · AuthRequiredError

${probe.detail}

Error message

${probe.detail}

What it means

An AuthRequiredError rethrowing the in-page probe's detail when the Google Account link's aria-label can't be parsed. The probe looks for `a[aria-label^="Google Account:"]` and extracts the account name with a regex; if the label exists but doesn't match the expected pattern, it reports kind:'auth' with an 'unparseable' detail, signaling the session state is unverified.

Source

Thrown at clis/gemini/auth.js:30

    throw new AuthRequiredError('gemini.google.com', 'Google session cookies (SID / SAPISID) missing');
  }
  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` to establish a fully verified session
  2. Confirm cookies via `opencli gemini whoami` / the site auth status command
  3. Check the account label format in the automation browser and update the regex in clis/gemini/auth.js if Google changed it
  4. Force the browser locale to English so the aria-label matches the expected prefix

Example fix

// before
const m = label.match(/^Google Account: (.+?)(?: \(|$)/);
// after
const m = label.match(/^Google Account:\s*(.+?)(?: \(|$)/); // tolerate spacing/format changes
Defensive patterns

Strategy: validation

Validate before calling

const label = await getAccountAriaLabel();
if (!/^Google Account: .+/.test(label)) {
  await relogin(); // label format unexpected — refresh session
}

Type guard

function isParsedAccount(probe) { return probe?.ok === true && typeof probe.name === 'string' && probe.name.length > 0; }

Try / catch

try {
  const identity = await getGeminiIdentity();
} catch (e) {
  if (e.name === 'AuthRequiredError' && /unparseable/.test(e.message)) {
    await geminiLogin(); // re-establish a verifiable session
  } else throw e;
}

Prevention

When it happens

Trigger: Inside verifyGeminiIdentity: the probe result has kind==='auth' — an account aria-label was found but `Google Account: <name>...` regex match failed, e.g. `Gemini aria-label unparseable: ...`.

Common situations: Google changed the aria-label format or locale (non-English label text); cookie present but page served a logged-out/interstitial state; partial login where account chip renders differently.

Related errors


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