{"record":{"id":"6d1074adb156100a","repo":"jackwener/OpenCLI","slug":"facebook-marketplace-listings-limit-must-be-a-po","errorCode":null,"errorMessage":"facebook marketplace-listings --limit must be a positive integer","messagePattern":"facebook marketplace-listings --limit must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/facebook/marketplace-listings.js","lineNumber":7,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\n\nfunction normalizeLimit(value) {\n  const limit = Number(value ?? 20);\n  if (!Number.isInteger(limit) || limit <= 0) {\n    throw new ArgumentError('facebook marketplace-listings --limit must be a positive integer');\n  }\n  return Math.min(limit, 100);\n}\n\ncli({\n  site: 'facebook',\n  name: 'marketplace-listings',\n    access: 'read',\n  description: 'List your Facebook Marketplace seller listings',\n  domain: 'www.facebook.com',\n  strategy: Strategy.COOKIE,\n  args: [\n    { name: 'limit', type: 'int', default: 20, help: 'Number of listings to return' },\n  ],\n  columns: ['index', 'title', 'price', 'status', 'listed', 'clicks', 'actions'],\n  func: async (page, args) => {\n    if (!page) throw new CommandExecutionError('Browser session required for facebook marketplace-listings');\n    const limit = normalizeLimit(args.limit);","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/facebook/marketplace-listings.js#L1-L25","documentation":"ArgumentError from normalizeLimit when the --limit value for facebook marketplace-listings is not a positive integer. The helper coerces the arg with Number() and rejects NaN, non-integers, zero and negatives before clamping to 100. It validates input early so the command never runs with a nonsensical limit.","triggerScenarios":"Calling the CLI with `--limit 0`, `--limit -5`, `--limit abc`, `--limit 2.5`, or any value that Number() cannot turn into a positive integer.","commonSituations":"Typo like `--limit=twenty`; shell variable expanding empty/undefined then being coerced to NaN (note: empty string coerces to 0, which also fails); scripting with user-supplied values not validated upstream.","solutions":["Pass a positive integer, e.g. `--limit 20` (max 100)","Validate the value before invoking the CLI: Number.isInteger(limit) && limit > 0","If using a shell variable, ensure it is set and numeric; unset vars become NaN","Drop the flag entirely to use the default of 20"],"exampleFix":"// before\ncli --site facebook marketplace-listings --limit 0\n// after\ncli --site facebook marketplace-listings --limit 20","handlingStrategy":"validation","validationCode":"function validateLimit(raw) {\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n <= 0) throw new Error(`--limit must be a positive integer, got ${JSON.stringify(raw)}`);\n  return Math.min(n, 100);\n}","typeGuard":"const isPositiveInt = (v) => Number.isInteger(Number(v)) && Number(v) > 0;","tryCatchPattern":"try {\n  await runMarketplaceListings({ limit });\n} catch (e) {\n  if (/--limit must be a positive integer/.test(e.message)) {\n    console.error('Bad --limit; using default 20');\n  } else throw e;\n}","preventionTips":["Validate numeric args before invoking the CLI","Never pass unset shell variables as --limit","Remember the hard cap of 100 (values are clamped, not rejected)","Prefer omitting --limit to use the default 20"],"tags":["argument-validation","cli-input"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}