{"record":{"id":"192ab64c04982a4c","repo":"jackwener/OpenCLI","slug":"auth-192ab6","errorCode":"AUTH","errorMessage":"AUTH","messagePattern":"AUTH","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/grok/export-all.js","lineNumber":71,"sourceCode":"  await page.wait(2);\n  const rawResult = await page.evaluate(`(async () => {\n    const targetLimit = ${JSON.stringify(limit > 0 ? offset + limit : 0)};\n    const maxScrolls = ${JSON.stringify(maxScrolls)};\n    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n    const isVisible = (node) => {\n      if (!(node instanceof Element)) return false;\n      const style = window.getComputedStyle(node);\n      if (style.visibility === 'hidden' || style.display === 'none') return false;\n      const rect = node.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0;\n    };\n    const hasHistoryEntry = Boolean(document.querySelector('a[href^=\"/c/\"]'));\n    const hasHistoryLauncher = Array.from(document.querySelectorAll('button, [role=\"button\"]'))\n      .some((node) => isVisible(node) && /^(查看全部|show all|view all)$/i.test((node.textContent || '').trim()));\n    const signInCta = Array.from(document.querySelectorAll('button, a'))\n      .some((node) => isVisible(node) && /^(sign in|log in)$/i.test((node.textContent || '').trim()));\n    if (signInCta && !hasHistoryEntry && !hasHistoryLauncher) {\n      return { ok: false, code: 'AUTH' };\n    }\n\n    const clickAllHistory = () => {\n      const buttons = Array.from(document.querySelectorAll('button, [role=\"button\"]'))\n        .filter((node) => node instanceof HTMLElement && isVisible(node));\n      const target = buttons.find((node) => /^(查看全部|show all|view all)$/i.test((node.textContent || '').trim()));\n      if (!target) return false;\n      target.click();\n      return true;\n    };\n\n    if (!document.querySelector('[role=\"listbox\"] a[href^=\"/c/\"]')) {\n      clickAllHistory();\n    }\n\n    let listbox = null;\n    for (let attempt = 0; attempt < 30; attempt += 1) {\n      listbox = document.querySelector('[role=\"listbox\"]');","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/export-all.js#L53-L89","documentation":"Inside collectHistory's page.evaluate for grok export-all, the script detects sign-in CTAs (buttons/links reading 'Sign in'/'Log in') while no history entries or history launcher exist, and returns { ok:false, code:'AUTH' }. The Node side surfaces this as an AUTH error meaning grok does not consider this browser session logged in, so conversation history cannot be exported.","triggerScenarios":"Running the grok export when the browser profile has no valid grok.com session: cookies expired/cleared, logged out manually, or the CLI attached to a fresh profile that never logged in — combined with the history sidebar showing no '/c/' entries and no 'Show all' launcher.","commonSituations":"Site logged you out after a password change or security sweep; using an automation profile (fresh Chrome profile) instead of your daily browser; cookie expiry after ~weeks; account region/SSO change requiring re-login.","solutions":["Open grok.com in the connected Chrome/Chromium profile and sign in manually, then re-run the export","Verify the CLI is attached to the browser profile you actually use (not a clean automation profile)","After logging in, confirm the left sidebar shows past conversations before re-running","Re-run the command — the page-state sniff is re-evaluated each run"],"exampleFix":"// before\n$ opencli grok export-all   # AUTH error on fresh profile\n// after\n$ opencli browser connect --profile daily   # attach to logged-in profile\n$ opencli grok export-all","handlingStrategy":"fallback","validationCode":"// Before exporting, verify the session:\nconst ok = await page.evaluate(() => Boolean(document.querySelector('a[href^=\"/c/\"]')));\nif (!ok) throw new Error('Not logged in to grok — open grok.com and sign in first');","typeGuard":null,"tryCatchPattern":"try {\n  await grokExportAll();\n} catch (e) {\n  if (String(e.message).trim() === 'AUTH' || /AUTH/.test(e.code ?? e.message)) {\n    console.error('Grok session invalid — open grok.com in the connected browser and sign in.');\n  } else throw e;\n}","preventionTips":["Run exports against the browser profile where you actively use grok.com","Re-login after password changes or long gaps between runs","Spot-check that the sidebar shows conversations before scripted exports","Treat AUTH as terminal: prompt for manual login instead of retrying"],"tags":["auth","session-expired","grok","browser"],"backgroundTag":"login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}