jackwener/OpenCLI · error · ArgumentError
coingecko limit must be <= 100
Error message
coingecko limit must be <= 100
What it means
CoinGecko's categories endpoint caps results, so the CLI rejects --limit greater than 100 with an ArgumentError even if the value is a valid positive integer. The help text notes CoinGecko returns roughly 120 categories max.
Source
Thrown at clis/coingecko/categories.js:36
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.',
);
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko categories returned HTTP ${resp.status}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Set --limit to 100 or less
- Omit --limit (default 20) and use --sort to prioritize what you need
- Fetch the full list in pages of <=100 if you need more entries
Example fix
// before node categories.js --limit 500 // after node categories.js --limit 100
Defensive patterns
Strategy: validation
Validate before calling
const limit = Number(args.limit ?? 20);
if (Number.isInteger(limit) && limit > 100) {
throw new Error('coingecko limit must be <= 100');
} Type guard
function isWithinApiLimit(v) {
const n = Number(v);
return Number.isInteger(n) && n > 0 && n <= 100;
} Try / catch
try {
await runCategories({ limit });
} catch (err) {
if (err instanceof ArgumentError) console.error('Clamp limit to 1-100:', err.message);
else throw err;
} Prevention
- Clamp limit to Math.min(limit, 100) in wrapper scripts
- Remember CoinGecko categories has a natural max (~120 rows)
- Paginate or slice client-side instead of requesting oversized limits
When it happens
Trigger: --limit 101 or higher on clis/coingecko/categories.js.
Common situations: Requesting all categories by setting a huge limit; assuming the CLI paginates or forwards arbitrary limits to the API.
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 a positive integer
- 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/10275f6f1d6de695.
Report an issue: GitHub.