{"record":{"id":"1a5cef196651fbb8","repo":"jackwener/OpenCLI","slug":"coingecko-coin-id-cannot-be-empty","errorCode":null,"errorMessage":"coingecko coin id cannot be empty","messagePattern":"coingecko coin id cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/coin.js","lineNumber":29,"sourceCode":"    name: 'coin',\n    access: 'read',\n    description: 'Fetch a single cryptocurrency\\'s market data by CoinGecko id (e.g. bitcoin, ethereum).',\n    domain: 'api.coingecko.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'id', positional: true, required: true, type: 'string', help: 'CoinGecko coin id (lowercase, e.g. bitcoin / ethereum / solana).' },\n        { name: 'currency', type: 'string', default: 'usd', help: 'Quote currency (usd, cny, eur, jpy, ...).' },\n    ],\n    columns: [\n        'id', 'symbol', 'name', 'rank', 'price', 'marketCap', 'volume24h',\n        'change24hPct', 'change7dPct', 'change30dPct', 'ath', 'athDate', 'atl', 'atlDate',\n        'circulatingSupply', 'totalSupply', 'maxSupply', 'genesisDate', 'homepage',\n    ],\n    func: async (args) => {\n        const id = String(args.id ?? '').trim().toLowerCase();\n        if (!id) {\n            throw new ArgumentError('coingecko coin id cannot be empty', 'Example: opencli coingecko coin bitcoin');\n        }\n        if (!/^[a-z0-9][a-z0-9-]*$/.test(id)) {\n            throw new ArgumentError(`coingecko coin id must look like a CoinGecko slug (got \"${args.id}\")`);\n        }\n        const currency = String(args.currency ?? 'usd').trim().toLowerCase();\n        if (!/^[a-z0-9-]{2,20}$/.test(currency)) {\n            throw new ArgumentError(`coingecko currency must look like a currency slug (got \"${args.currency}\")`);\n        }\n\n        const url = new URL(`https://api.coingecko.com/api/v3/coins/${id}`);\n        url.searchParams.set('localization', 'false');\n        url.searchParams.set('tickers', 'false');\n        url.searchParams.set('market_data', 'true');\n        url.searchParams.set('community_data', 'false');\n        url.searchParams.set('developer_data', 'false');\n        url.searchParams.set('sparkline', 'false');\n\n        let resp;","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/coin.js#L11-L47","documentation":"This ArgumentError is thrown by the `coingecko coin` command when the required positional `id` argument is missing or empty after normalization (trim/lowercase of String(args.id ?? '')). The command needs a CoinGecko coin slug (e.g. 'bitcoin') to build the API URL https://api.coingecko.com/api/v3/coins/{id}, so an empty id would produce an invalid request. The error message includes an example usage to guide the caller.","triggerScenarios":"Calling `opencli coingecko coin` with no positional id, passing an empty string (''), whitespace-only string ('   '), or an arg that normalizes to empty (e.g. null/undefined coerced via args.id ?? '').","commonSituations":"Scripting the CLI where a variable holding the coin id is unset or empty; piping data where the id column was blank; copying a command template and forgetting to fill in the coin name.","solutions":["Pass a valid CoinGecko coin id as the first positional argument, e.g. `opencli coingecko coin bitcoin`","Check that the variable or pipeline feeding the id is non-empty before invoking the command","Look up the correct coin id via CoinGecko's search API or website if unsure of the slug"],"exampleFix":"// before\nopencli coingecko coin\n// after\nopencli coingecko coin bitcoin","handlingStrategy":"validation","validationCode":"const id = (process.argv[3] ?? '').trim().toLowerCase();\nif (!id) { console.error('Usage: opencli coingecko coin <id>'); process.exit(2); }","typeGuard":"const isNonEmpty = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try { await run(['coingecko', 'coin', id]); } catch (e) { if (e instanceof ArgumentError) { console.error('Missing/invalid arg:', e.message); process.exit(2); } throw e; }","preventionTips":["Always pass the id positionally: `opencli coingecko coin bitcoin`","Validate that the variable feeding the id is non-empty before invoking","Escape shell scripts against unset variables (set -u in bash)"],"tags":["cli","argument-validation","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}