jackwener/OpenCLI · error · ArgumentError
coingecko sort "${args.sort}" is not supported
Error message
coingecko sort "${args.sort}" is not supported What it means
The coingecko categories CLI validates the --sort argument against a fixed allowlist (ORDER_OPTIONS) and throws ArgumentError for anything else. The sort string is normalized (trimmed, lowercased) before the check, so only genuinely unsupported values trigger this.
Source
Thrown at clis/coingecko/categories.js:26
const ORDER_OPTIONS = ['market_cap_desc', 'market_cap_asc', 'name_desc', 'name_asc', 'market_cap_change_24h_desc', 'market_cap_change_24h_asc'];
cli({
site: 'coingecko',
name: 'categories',
access: 'read',
description: 'Crypto categories ranked by aggregated market cap',
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}`);View on GitHub (pinned to 49907e53dc)
Solutions
- Use one of the supported sorts listed in the error message (the ORDER_OPTIONS values)
- Run the command with --help to see valid --sort values
- Remove the --sort flag to use the default 'market_cap_desc'
Example fix
// before node categories.js --sort volume_desc // after node categories.js --sort market_cap_desc
Defensive patterns
Strategy: validation
Validate before calling
const ORDER_OPTIONS = ['market_cap_desc' /* ...actual list */];
const sort = String(args.sort ?? 'market_cap_desc').trim().toLowerCase();
if (!ORDER_OPTIONS.includes(sort)) {
throw new Error(`Unsupported sort ${args.sort}; use one of: ${ORDER_OPTIONS.join(', ')}`);
} Type guard
function isValidSort(v, allowed) {
return typeof v === 'string' && allowed.includes(v.trim().toLowerCase());
} Try / catch
try {
await runCategories({ sort });
} catch (err) {
if (err instanceof ArgumentError) console.error(err.hint ?? err.message);
else throw err;
} Prevention
- Run with --help to enumerate valid --sort values
- Normalize case/whitespace before passing sort values
- Keep a constant list of allowed sorts in wrapper scripts
When it happens
Trigger: Passing --sort with a value not in ORDER_OPTIONS, e.g. --sort volume_desc or --sort MarketCap on clis/coingecko/categories.js.
Common situations: Copying sort keys from other CoinGecko endpoints with different order enums; capitalization or typo mistakes; assuming arbitrary CoinGecko API order values are accepted.
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 limit must be a positive integer
- 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/61b0b47cb53d2e40.
Report an issue: GitHub.