{"record":{"id":"2de277df5c0dd372","repo":"jackwener/OpenCLI","slug":"grok-export-all","errorCode":null,"errorMessage":"grok export-all","messagePattern":"grok export-all","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/grok/export-all.js","lineNumber":46,"sourceCode":"  if (maxMs <= 0) return;\n  const span = Math.max(0, maxMs - minMs);\n  const ms = minMs + Math.floor(Math.random() * (span + 1));\n  if (ms > 0) await page.wait(ms / 1000);\n}\n\nfunction readManifest(manifestPath, { offset, limit }) {\n  const path = String(manifestPath || '').trim();\n  if (!path) return null;\n  let parsed;\n  try {\n    parsed = JSON.parse(fs.readFileSync(path, 'utf8'));\n  } catch (error) {\n    throw new ArgumentError('manifestPath', `failed to read JSON manifest: ${error?.message || error}`);\n  }\n  const rows = normalizeManifestRows(parsed);\n  const sliced = limit ? rows.slice(offset, offset + limit) : rows.slice(offset);\n  if (!sliced.length) {\n    throw new EmptyResultError('grok export-all', `No manifest rows after offset=${offset}, limit=${limit}`);\n  }\n  return sliced;\n}\n\nasync function collectHistory(page, { offset, limit, maxScrolls }) {\n  await page.goto(GROK_URL);\n  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    };","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/export-all.js#L28-L64","documentation":"EmptyResultError('grok export-all') thrown by readManifest when, after applying offset (and limit) slicing to the manifest rows, no rows remain. It means the manifest was read fine but the requested window is empty.","triggerScenarios":"clis/grok/export-all.js:46 throws when normalizeManifestRows yields rows but rows.slice(offset, offset+limit) (or rows.slice(offset)) is empty — i.e. offset >= rows.length or the manifest only contains rows that normalize away.","commonSituations":"Offset past the end of the manifest on the final pagination page; manifest with an empty or malformed rows array; reusing a large offset from a previous, larger manifest.","solutions":["Lower the offset or drop it to re-read from the start","Check the manifest row count: rows.length vs your offset/limit","Stop paginating when offset >= total rows instead of calling again","Regenerate the manifest if it is stale/empty"],"exampleFix":"// before\ncli.exportAll({ manifestPath: 'm.json', offset: 500 }); // manifest has 12 rows\n// after\ncli.exportAll({ manifestPath: 'm.json', offset: 0, limit: 12 });","handlingStrategy":"try-catch","validationCode":"const rows = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\nif (offset >= rows.length) throw new Error(`offset ${offset} exceeds manifest rows ${rows.length}`);","typeGuard":null,"tryCatchPattern":"try { await cli.exportAll({ manifestPath, offset, limit }); } catch (e) { if (e.name === 'EmptyResultError') return []; throw e; } // treat as end of pagination","preventionTips":["Track total row count and stop paginating when offset >= total","Regenerate manifests that may be stale or truncated","Normalize rows yourself to confirm count before slicing","Start with offset 0 when switching manifests"],"tags":["empty-result","pagination","manifest"],"backgroundTag":"empty-result-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}