{"record":{"id":"592f97a384fe889e","repo":"jackwener/OpenCLI","slug":"max-scrolls-must-be-an-integer-between-0-and-80","errorCode":null,"errorMessage":"--max-scrolls must be an integer between 0 and 80","messagePattern":"--max-scrolls must be an integer between 0 and 80","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/thread-snapshot.js","lineNumber":28,"sourceCode":"const LINKEDIN_DOMAIN = 'www.linkedin.com';\n\nfunction requireStringArg(args, key, label = key) {\n  const value = normalizeWhitespace(args[key]);\n  if (!value) throw new ArgumentError(`${label} is required`);\n  return value;\n}\n\nfunction requireLinkedInThreadUrl(value, label) {\n  const url = canonicalizeLinkedInThreadUrl(value);\n  if (!url) throw new ArgumentError(`${label} must be an exact https://www.linkedin.com/messaging/thread/<id>/ URL`);\n  return url;\n}\n\nfunction parseMaxScrolls(value) {\n  if (value === undefined || value === null || value === '') return 30;\n  const scrolls = Number(value);\n  if (!Number.isInteger(scrolls) || scrolls < 0 || scrolls > 80) {\n    throw new ArgumentError('--max-scrolls must be an integer between 0 and 80');\n  }\n  return scrolls;\n}\n\nfunction buildThreadApiDiscoveryScript(maxScrolls) {\n  return String.raw`(async () => {\n    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n    const pageText = document.body ? (document.body.innerText || '') : '';\n    const authRequired = /\\b(sign in|log in|join linkedin)\\b/i.test(pageText)\n      || /linkedin\\.com\\/(login|checkpoint|authwall|uas)/i.test(location.href)\n      || /captcha|verification required/i.test(pageText);\n\n    const selectors = [\n      '.msg-s-message-list',\n      '.msg-s-message-list-scrollable',\n      '.msg-thread',\n      'main [role=\"main\"]',\n      'main'","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/thread-snapshot.js#L10-L46","documentation":"parseMaxScrolls converts the --max-scrolls argument to a number and throws ArgumentError unless it is an integer between 0 and 80 inclusive. It defaults to 30 when the value is undefined/null/empty, so the error only fires for out-of-range or non-integer values. This caps scroll work during thread snapshot collection.","triggerScenarios":"Running thread-snapshot with e.g. `--max-scrolls 100` (above 80), `--max-scrolls -1` (below 0), `--max-scrolls 2.5` (non-integer), or `--max-scrolls unlimited` (non-numeric).","commonSituations":"Users wanting deeper history assuming a higher cap is allowed; scripts interpolating invalid values; mistaking the flag for a boolean and passing a stray token.","solutions":["Use an integer from 0 to 80, e.g. --max-scrolls 80 for maximum history.","Omit the flag to use the default of 30.","Replace non-numeric strings ('all') with a number in range.","Clamp in scripts before invoking: Math.min(80, Math.max(0, Math.round(value)))."],"exampleFix":"// before\nnode cli.js thread-snapshot --thread-url \"$URL\" --max-scrolls 200\n// after\nnode cli.js thread-snapshot --thread-url \"$URL\" --max-scrolls 80","handlingStrategy":"validation","validationCode":"function assertMaxScrolls(v) {\n  if (v === undefined || v === null || v === '') return 30;\n  const n = Number(v);\n  if (!Number.isInteger(n) || n < 0 || n > 80) {\n    throw new Error('--max-scrolls must be an integer between 0 and 80');\n  }\n  return n;\n}","typeGuard":"const maxScrollsOk = (v) => v === undefined || v === null || v === '' ||\n  (Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= 80);","tryCatchPattern":"try {\n  await threadSnapshot({ 'thread-url': url, 'max-scrolls': scrolls });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.startsWith('--max-scrolls')) {\n    console.error('Invalid --max-scrolls; using 30 (allowed: integer 0..80).');\n  } else throw e;\n}","preventionTips":["80 is the hard cap; for deeper history use 80, not larger numbers.","Omit the flag to use the default of 30.","Pass plain integers — 'all' or decimals are rejected.","Clamp computed values in scripts: Math.min(80, Math.max(0, Math.round(n)))."],"tags":["argument-validation","cli-flags","range-validation","linkedin"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}