{"record":{"id":"049676bec7248cb4","repo":"jackwener/OpenCLI","slug":"facebook-marketplace-inbox-limit-must-be-a-posit","errorCode":null,"errorMessage":"facebook marketplace-inbox --limit must be a positive integer","messagePattern":"facebook marketplace-inbox --limit must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/facebook/marketplace-inbox.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-inbox --limit must be a positive integer');\n  }\n  return Math.min(limit, 100);\n}\n\ncli({\n  site: 'facebook',\n  name: 'marketplace-inbox',\n    access: 'read',\n  description: 'List recent Facebook Marketplace buyer/seller conversations',\n  domain: 'www.facebook.com',\n  strategy: Strategy.COOKIE,\n  args: [\n    { name: 'limit', type: 'int', default: 20, help: 'Number of conversations to return' },\n  ],\n  columns: ['index', 'buyer', 'listing', 'snippet', 'time', 'unread'],\n  func: async (page, args) => {\n    if (!page) throw new CommandExecutionError('Browser session required for facebook marketplace-inbox');\n    const limit = normalizeLimit(args.limit);","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/facebook/marketplace-inbox.js#L1-L25","documentation":"normalizeLimit validates the --limit argument for the facebook marketplace-inbox command: the value (default 20) must be a positive integer, otherwise it throws ArgumentError('facebook marketplace-inbox --limit must be a positive integer'). Valid values are capped at 100.","triggerScenarios":"Calling the marketplace-inbox command with --limit 0, a negative number, a non-integer (e.g. 2.5), or a non-numeric string such as --limit abc or --limit '10x'.","commonSituations":"Shell scripts interpolating empty/unset variables into --limit; users passing floats or strings copied from docs; automation templates with malformed defaults; forgetting that 0 is rejected.","solutions":["Pass a positive integer, e.g. --limit 20 (max 100).","Check the shell variable feeding --limit is set and numeric.","Quote/validate inputs in scripts before invoking the command.","Omit --limit entirely to use the default of 20."],"exampleFix":"// before\nopencli facebook marketplace-inbox --limit \"$LIMIT\"\n// after\nLIMIT=${LIMIT:-20}\nopencli facebook marketplace-inbox --limit \"$((LIMIT > 0 ? LIMIT : 20))\"","handlingStrategy":"validation","validationCode":"function parseLimit(raw, fallback = 20) {\n  const v = raw ?? fallback;\n  const n = Number(v);\n  if (!Number.isInteger(n) || n <= 0) throw new TypeError('--limit must be a positive integer');\n  return Math.min(n, 100);\n}\n// run parseLimit(process.argv.limit) before invoking the command","typeGuard":"function isValidLimit(v) {\n  return Number.isInteger(Number(v)) && Number(v) > 0;\n}","tryCatchPattern":"try {\n  await cli.run(['facebook', 'marketplace-inbox', '--limit', String(limit)]);\n} catch (err) {\n  if (/--limit must be a positive integer/.test(err.message)) {\n    limit = 20; // fall back to default\n  } else throw err;\n}","preventionTips":["Validate/normalize limit inputs in scripts before passing --limit.","Guard shell variables so empty/unset values fall back to 20.","Pass integers only; avoid floats and non-numeric strings.","Omit --limit to use the built-in default of 20."],"tags":["argument-validation","cli","input"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}