{"record":{"id":"61b0b47cb53d2e40","repo":"jackwener/OpenCLI","slug":"coingecko-sort-args-sort-is-not-supported","errorCode":null,"errorMessage":"coingecko sort \"${args.sort}\" is not supported","messagePattern":"coingecko sort \"(.+?)\" is not supported","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/categories.js","lineNumber":26,"sourceCode":"const ORDER_OPTIONS = ['market_cap_desc', 'market_cap_asc', 'name_desc', 'name_asc', 'market_cap_change_24h_desc', 'market_cap_change_24h_asc'];\n\ncli({\n    site: 'coingecko',\n    name: 'categories',\n    access: 'read',\n    description: 'Crypto categories ranked by aggregated market cap',\n    domain: 'api.coingecko.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'sort', default: 'market_cap_desc', help: `Sort order (${ORDER_OPTIONS.join(' / ')})` },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of categories (1-100; CoinGecko returns ~120 max)' },\n    ],\n    columns: ['rank', 'id', 'name', 'marketCap', 'volume24h', 'marketCapChange24hPct', 'top3Coins'],\n    func: async (args) => {\n        const sort = String(args.sort ?? 'market_cap_desc').trim().toLowerCase();\n        if (!ORDER_OPTIONS.includes(sort)) {\n            throw new ArgumentError(\n                `coingecko sort \"${args.sort}\" is not supported`,\n                `Supported sorts: ${ORDER_OPTIONS.join(', ')}`,\n            );\n        }\n        const limit = Number(args.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('coingecko limit must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('coingecko limit must be <= 100');\n        }\n        const url = `https://api.coingecko.com/api/v3/coins/categories?order=${encodeURIComponent(sort)}`;\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`coingecko categories request failed: ${err?.message ?? err}`);","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/categories.js#L8-L44","documentation":"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.","triggerScenarios":"Passing --sort with a value not in ORDER_OPTIONS, e.g. --sort volume_desc or --sort MarketCap on clis/coingecko/categories.js.","commonSituations":"Copying sort keys from other CoinGecko endpoints with different order enums; capitalization or typo mistakes; assuming arbitrary CoinGecko API order values are accepted.","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'"],"exampleFix":"// before\nnode categories.js --sort volume_desc\n// after\nnode categories.js --sort market_cap_desc","handlingStrategy":"validation","validationCode":"const ORDER_OPTIONS = ['market_cap_desc' /* ...actual list */];\nconst sort = String(args.sort ?? 'market_cap_desc').trim().toLowerCase();\nif (!ORDER_OPTIONS.includes(sort)) {\n  throw new Error(`Unsupported sort ${args.sort}; use one of: ${ORDER_OPTIONS.join(', ')}`);\n}","typeGuard":"function isValidSort(v, allowed) {\n  return typeof v === 'string' && allowed.includes(v.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  await runCategories({ sort });\n} catch (err) {\n  if (err instanceof ArgumentError) console.error(err.hint ?? err.message);\n  else throw err;\n}","preventionTips":["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"],"tags":["argument-error","validation","cli","coingecko"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}