{"record":{"id":"34d73b2480ef6cbd","repo":"jackwener/OpenCLI","slug":"facebook-feed-limit-must-be-an-integer-between","errorCode":null,"errorMessage":"`facebook feed --limit must be an integer between 1 and ${MAX_LIMIT}`","messagePattern":"`facebook feed --limit must be an integer between 1 and (.+?)`","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/facebook/feed.js","lineNumber":10,"sourceCode":"import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\n\nconst FACEBOOK_HOME = 'https://www.facebook.com/';\nconst MAX_LIMIT = 50;\n\nfunction requireLimit(value) {\n  const n = Number(value);\n  if (!Number.isInteger(n) || n < 1 || n > MAX_LIMIT) {\n    throw new ArgumentError(`facebook feed --limit must be an integer between 1 and ${MAX_LIMIT}`);\n  }\n  return n;\n}\n\nfunction unwrapBrowserResult(value) {\n  if (value && typeof value === 'object' && 'data' in value) {\n    return value.data;\n  }\n  return value;\n}\n\nfunction buildFeedExtractScript(limit) {\n  return `(() => {\n    const limit = ${limit};\n\n    function clean(value) {\n      // Strip zero-width / bidi control chars first: Facebook injects them into\n      // decoy nodes to poison scrapers. See issue #2089.","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/facebook/feed.js#L1-L28","documentation":"requireLimit validates the --limit argument for the facebook feed command: it must parse to an integer between 1 and MAX_LIMIT (50). Anything else — non-numeric strings, floats, zero, negatives, or values above 50 — throws ArgumentError. The validated number is returned and used to cap how many feed items are scraped.","triggerScenarios":"Running facebook feed with --limit set to e.g. 'abc' (NaN), 2.5 (non-integer), 0, -1, or 51+ (exceeds MAX_LIMIT=50).","commonSituations":"Typos like --limit 5o or --limit=; assuming an unlimited/higher cap and passing 100; scripting the flag with a float from a computation; forgetting the flag's valid range entirely.","solutions":["Pass an integer between 1 and 50, e.g. facebook feed --limit 20.","If you need more than 50 items, paginate by running the command repeatedly instead of raising the limit.","Sanitize/round the value in your script before passing it: Math.min(50, Math.max(1, Math.round(n))).","Check the flag spelling: --limit takes one numeric value with no units or extra characters."],"exampleFix":"// before\nconst n = Number(userInput);\nawait feed({ limit: n }); // throws when n is NaN, 2.5, or > 50\n\n// after\nconst n = Math.min(50, Math.max(1, Math.round(Number(userInput))));\nif (Number.isInteger(n)) await feed({ limit: n });","handlingStrategy":"validation","validationCode":"function parseLimit(value) {\n  const n = Number(value);\n  return Number.isInteger(n) && n >= 1 && n <= 50 ? n : null;\n}\nconst limit = parseLimit(rawFlag);\nif (limit === null) limit = 20; // default instead of throwing","typeGuard":"function isValidLimit(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 50;\n}","tryCatchPattern":"try {\n  const n = requireLimit(args.limit);\n} catch (err) {\n  if (err instanceof ArgumentError) {\n    console.error('Usage: facebook feed --limit <1-50>');\n    process.exitCode = 2;\n  } else {\n    throw err;\n  }\n}","preventionTips":["Clamp and round user input: Math.min(50, Math.max(1, Math.round(n))).","Document the 1–50 range in --help text.","For larger fetches, paginate multiple runs instead of raising the limit.","Validate numeric flags at the CLI boundary before passing them downstream."],"tags":["validation","cli","arguments","facebook"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}