{"record":{"id":"2b801967532f83de","repo":"jackwener/OpenCLI","slug":"must-be-min","errorCode":null,"errorMessage":"must be >= ${min}","messagePattern":"must be >= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/grok/export-all.js","lineNumber":19,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, EmptyResultError, TimeoutError } from '@jackwener/opencli/errors';\nimport fs from 'node:fs';\nimport {\n  normalizeConversationRows,\n  normalizeManifestRows,\n  requireBooleanEvaluateResult,\n  requireObjectEvaluateResult,\n} from './export-utils.js';\nimport { GROK_DOMAIN, GROK_URL } from './utils.js';\n\nfunction normalizeInteger(value, defaultValue, label, { min = 0, max = Number.MAX_SAFE_INTEGER } = {}) {\n  const raw = value ?? defaultValue;\n  const n = Number(raw);\n  if (!Number.isInteger(n)) {\n    throw new ArgumentError(label, `must be an integer`);\n  }\n  if (n < min) {\n    throw new ArgumentError(label, `must be >= ${min}`);\n  }\n  if (n > max) {\n    throw new ArgumentError(label, `must be <= ${max}`);\n  }\n  return n;\n}\n\nasync function waitRandom(page, minMs, maxMs) {\n  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;","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/export-all.js#L1-L37","documentation":"ArgumentError thrown by normalizeInteger when an integer option is below its configured minimum. Each option (limit, offset, maxScrolls, pageScrolls, pageTimeoutMs, delayMinMs) carries a min bound; negative or too-small values are rejected before the scrape starts.","triggerScenarios":"Passing a value < min to any validated option, e.g. offset=-1, maxScrolls=-5, or a below-minimum pageTimeoutMs/delayMinMs.","commonSituations":"Negative offsets computed as prevOffset-offset without clamping; scripts computing timeouts from metrics that can be 0/negative; typos like --offset=-10.","solutions":["Clamp the value with Math.max(min, value) before calling","Use 0 or the documented minimum for offset/limit","Check your offset pagination math for sign errors","Inspect each option's min bound and supply a compliant value"],"exampleFix":"// before\ncli.exportAll({ offset: -1 });\n// after\ncli.exportAll({ offset: Math.max(0, computedOffset) });","handlingStrategy":"validation","validationCode":"function clampMin(n, min) { if (n < min) throw new Error(`value ${n} must be >= ${min}`); return n; }","typeGuard":"const isIntGte = (v, min) => Number.isInteger(v) && v >= min;","tryCatchPattern":"try { await cli.exportAll(opts); } catch (e) { if (e.name === 'ArgumentError' && />= /.test(e.message)) { console.error(`Below minimum: ${e.message}`); } else throw e; }","preventionTips":["Clamp computed values with Math.max(min, v)","Re-check pagination arithmetic for negative offsets","Use 0 for 'no offset' instead of negative sentinels","Validate options against documented min bounds before calls"],"tags":["argument-validation","bounds-check","cli-input"],"backgroundTag":"invalid-argument-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}