{"record":{"id":"b9f9d99cf2047537","repo":"jackwener/OpenCLI","slug":"unexpected-gemini-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Gemini probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Gemini probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/auth.js","lineNumber":31,"sourceCode":"  }\n  await page.goto('https://gemini.google.com/app');\n  await page.wait(3);\n  const probe = await page.evaluate(`\n    (() => {\n      const a = document.querySelector('a[aria-label^=\"Google Account:\"]');\n      if (!a) {\n        return { kind: 'auth', detail: 'Gemini account link missing — not signed into Google' };\n      }\n      const label = a.getAttribute('aria-label') || '';\n      const m = label.match(/Google Account:\\\\s*([^(]+?)\\\\s*\\\\(([^)]+)\\\\)/);\n      if (!m) {\n        return { kind: 'auth', detail: 'Gemini aria-label unparseable: ' + label };\n      }\n      return { ok: true, name: m[1].trim() };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('gemini.google.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);\n  return { name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'gemini',\n  domain: 'gemini.google.com',\n  loginUrl: 'https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fgemini.google.com%2F',\n  columns: ['name'],\n  quickCheck: hasGoogleSessionCookie,\n  verify: verifyGeminiIdentity,\n  poll: async (page) => {\n    if (!await hasGoogleSessionCookie(page)) {\n      throw new AuthRequiredError('gemini.google.com', 'Waiting for Google session cookies');\n    }\n    return verifyGeminiIdentity(page);\n  },\n});\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/auth.js#L13-L49","documentation":"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').","triggerScenarios":"`probe` is null/undefined or an object without ok/kind flags after `page.evaluate(...)` in verifyGeminiIdentity (auth.js:31).","commonSituations":"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.","solutions":["Re-run `opencli gemini login` and retry the command","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","Check the browser bridge is healthy (no CDP disconnects) and re-run","Log the raw probe value at auth.js:31 to see the actual unexpected shape before fixing"],"exampleFix":"// before\nif (!probe?.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);\n// after\nif (!probe) throw new AuthRequiredError('gemini.google.com', 'Probe returned no result — session likely missing');\nif (!probe.ok) throw new CommandExecutionError(`Unexpected Gemini probe: ${JSON.stringify(probe)}`);","handlingStrategy":"type-guard","validationCode":"const probe = await page.evaluate(probeScript);\nif (!probe || typeof probe !== 'object') {\n  throw new AuthRequiredError('gemini.google.com', 'No probe result — session missing');\n}","typeGuard":"function isWellFormedProbe(p) {\n  return !!p && typeof p === 'object' &&\n    (p.ok === true || (p.kind === 'auth' && typeof p.detail === 'string'));\n}","tryCatchPattern":"try {\n  const identity = await getGeminiIdentity();\n} catch (e) {\n  if (/Unexpected Gemini probe/.test(e.message)) {\n    // inspect e.message JSON, then re-login or update the probe script\n  } else throw e;\n}","preventionTips":["Log raw probe results when the shape is unexpected","Ensure the in-page script always returns {ok} or {kind:'auth'} on every path","Keep the probe selector updated with Gemini's DOM","Check browser bridge health (no CDP disconnects) before probing"],"tags":["gemini","probe","browser-automation"],"backgroundTag":"unexpected-bridge-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}