jackwener/OpenCLI · error · ArgumentError
facebook marketplace-listings --limit must be a positive int
Error message
facebook marketplace-listings --limit must be a positive integer
What it means
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.
Source
Thrown at clis/facebook/marketplace-listings.js:7
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
function normalizeLimit(value) {
const limit = Number(value ?? 20);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError('facebook marketplace-listings --limit must be a positive integer');
}
return Math.min(limit, 100);
}
cli({
site: 'facebook',
name: 'marketplace-listings',
access: 'read',
description: 'List your Facebook Marketplace seller listings',
domain: 'www.facebook.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of listings to return' },
],
columns: ['index', 'title', 'price', 'status', 'listed', 'clicks', 'actions'],
func: async (page, args) => {
if (!page) throw new CommandExecutionError('Browser session required for facebook marketplace-listings');
const limit = normalizeLimit(args.limit);View on GitHub (pinned to 49907e53dc)
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
Example fix
// before cli --site facebook marketplace-listings --limit 0 // after cli --site facebook marketplace-listings --limit 20
Defensive patterns
Strategy: validation
Validate before calling
function validateLimit(raw) {
const n = Number(raw);
if (!Number.isInteger(n) || n <= 0) throw new Error(`--limit must be a positive integer, got ${JSON.stringify(raw)}`);
return Math.min(n, 100);
} Type guard
const isPositiveInt = (v) => Number.isInteger(Number(v)) && Number(v) > 0;
Try / catch
try {
await runMarketplaceListings({ limit });
} catch (e) {
if (/--limit must be a positive integer/.test(e.message)) {
console.error('Bad --limit; using default 20');
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling the CLI with `--limit 0`, `--limit -5`, `--limit abc`, `--limit 2.5`, or any value that Number() cannot turn into a positive integer.
Common situations: 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.
Related errors
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
- archive snapshots limit must be <= 1000
- archive snapshots ${key} must be a digit-only timestamp (YYY
- bilibili unfollow target must be a valid space.bilibili.com/
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6d1074adb156100a.
Report an issue: GitHub.