jackwener/OpenCLI · error · ArgumentError
coingecko limit must be a positive integer
Error message
coingecko limit must be a positive integer
What it means
The CLI validates --limit as a positive integer before calling the CoinGecko API. Number(args.limit) must be an integer > 0; otherwise ArgumentError is thrown. Note non-integer numbers and non-numeric strings both fail this check.
Source
Thrown at clis/coingecko/categories.js:33
domain: 'api.coingecko.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'sort', default: 'market_cap_desc', help: `Sort order (${ORDER_OPTIONS.join(' / ')})` },
{ name: 'limit', type: 'int', default: 20, help: 'Number of categories (1-100; CoinGecko returns ~120 max)' },
],
columns: ['rank', 'id', 'name', 'marketCap', 'volume24h', 'marketCapChange24hPct', 'top3Coins'],
func: async (args) => {
const sort = String(args.sort ?? 'market_cap_desc').trim().toLowerCase();
if (!ORDER_OPTIONS.includes(sort)) {
throw new ArgumentError(
`coingecko sort "${args.sort}" is not supported`,
`Supported sorts: ${ORDER_OPTIONS.join(', ')}`,
);
}
const limit = Number(args.limit ?? 20);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError('coingecko limit must be a positive integer');
}
if (limit > 100) {
throw new ArgumentError('coingecko limit must be <= 100');
}
const url = `https://api.coingecko.com/api/v3/coins/categories?order=${encodeURIComponent(sort)}`;
let resp;
try {
resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
}
catch (err) {
throw new CommandExecutionError(`coingecko categories request failed: ${err?.message ?? err}`);
}
if (resp.status === 429) {
throw new CommandExecutionError(
'coingecko returned HTTP 429 (rate limited)',
'Free tier allows ~30 calls/min. Wait and retry.',
);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a whole number >= 1, e.g. --limit 20
- Omit --limit to use the default of 20
- Validate/clamp the limit value in the calling script before invoking the CLI
Example fix
// before node categories.js --limit 0 // after node categories.js --limit 20
Defensive patterns
Strategy: validation
Validate before calling
const limit = Number(args.limit ?? 20);
if (!Number.isInteger(limit) || limit <= 0) {
throw new Error('coingecko limit must be a positive integer');
} Type guard
function isValidLimit(v) {
const n = Number(v);
return Number.isInteger(n) && n > 0;
} Try / catch
try {
await runCategories({ limit });
} catch (err) {
if (err instanceof ArgumentError) console.error('Bad --limit:', err.message);
else throw err;
} Prevention
- Quote/validate numeric CLI args in shell scripts
- Coerce and check Number.isInteger before passing user input
- Omit --limit to accept the safe default of 20
When it happens
Trigger: --limit 0, --limit -5, --limit abc, or a float like --limit 2.5 on clis/coingecko/categories.js.
Common situations: Scripting the CLI with an unvalidated variable; typos in a shell script; passing a computed value that became NaN or fractional.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- coingecko sort "${args.sort}" is not supported
- coingecko limit must be <= 100
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5087d57036bb4ab2.
Report an issue: GitHub.