{"record":{"id":"8429106048bdbd6e","repo":"jackwener/OpenCLI","slug":"coingecko-has-no-market-totals-for-currency-cur","errorCode":null,"errorMessage":"coingecko has no market totals for currency \"${currency}\"","messagePattern":"coingecko has no market totals for currency \"(.+?)\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/global.js","lineNumber":53,"sourceCode":"        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`coingecko global returned HTTP ${resp.status}`);\n        }\n        let body;\n        try {\n            body = await resp.json();\n        }\n        catch (err) {\n            throw new CommandExecutionError(`coingecko global returned malformed JSON: ${err?.message ?? err}`);\n        }\n        const data = body?.data;\n        if (!data) {\n            throw new CommandExecutionError('coingecko global returned no data envelope');\n        }\n        const totalMarketCap = data?.total_market_cap?.[currency];\n        const totalVolume = data?.total_volume?.[currency];\n        if (totalMarketCap == null && totalVolume == null) {\n            throw new ArgumentError(\n                `coingecko has no market totals for currency \"${currency}\"`,\n                'Use a CoinGecko-supported quote currency such as usd, cny, eur, or jpy.',\n            );\n        }\n        return [{\n            currency: currency.toUpperCase(),\n            totalMarketCap: totalMarketCap != null ? Number(totalMarketCap) : null,\n            totalVolume24h: totalVolume != null ? Number(totalVolume) : null,\n            marketCapChange24hPct: data.market_cap_change_percentage_24h_usd != null ? Number(data.market_cap_change_percentage_24h_usd) : null,\n            btcDominancePct: data?.market_cap_percentage?.btc != null ? Number(data.market_cap_percentage.btc) : null,\n            ethDominancePct: data?.market_cap_percentage?.eth != null ? Number(data.market_cap_percentage.eth) : null,\n            activeCryptocurrencies: data.active_cryptocurrencies != null ? Number(data.active_cryptocurrencies) : null,\n            markets: data.markets != null ? Number(data.markets) : null,\n            ongoingIcos: data.ongoing_icos != null ? Number(data.ongoing_icos) : null,\n            updatedAt: data.updated_at ? new Date(data.updated_at * 1000).toISOString() : '',\n        }];\n    },\n});","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/global.js#L35-L71","documentation":"This ArgumentError is thrown when the /global payload is valid but has neither total_market_cap[currency] nor total_volume[currency], meaning CoinGecko does not publish global market totals in the requested quote currency. It is an input-validation error: the currency argument is unsupported, not a network problem.","triggerScenarios":"Passing a currency arg that passes the slug regex (2-20 chars of a-z0-9-) but is not a CoinGecko-supported quote currency, e.g. 'gbp' typos like 'usdd', 'xyz', or an exotic/obsolete code.","commonSituations":"Users guessing at currency codes ('chf', 'inr' variants, 'aud' typos); scripts parameterizing currency from config with an unsupported value; locale-based currency strings like 'USD-US' or '$' leaking into the arg.","solutions":["Re-run with a widely supported currency such as usd, cny, eur, or jpy.","Check the exact currency code on CoinGecko's supported vs_currencies list (https://api.coingecko.com/api/v3/simple/supported_vs_currencies).","Check the spelling/case of the currency argument in your script or config.","Fall back to usd and convert locally if your currency is genuinely unsupported.","If the code is supported but still fails, verify via curl that /global includes your currency key in total_market_cap."],"exampleFix":"// before\nawait runCli('coingecko', 'global', ['--currency', 'xyz']);\n// after\nconst SUPPORTED = ['usd','cny','eur','jpy','gbp'];\nconst cur = SUPPORTED.includes(args.currency) ? args.currency : 'usd';\nawait runCli('coingecko', 'global', ['--currency', cur]);","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['usd','eur','gbp','jpy','cny','aud','cad','chf','hkd','sgd','inr','krw','brl','try','rub','zar','btc','eth','ltc','xrp']);\nif (!SUPPORTED.has(currency.toLowerCase())) throw new Error('unsupported quote currency: ' + currency);\n\nconst list = await (await fetch('https://api.coingecko.com/api/v3/simple/supported_vs_currencies')).json();\nif (!list.includes(currency.toLowerCase())) throw new Error('unsupported vs_currency: ' + currency);","typeGuard":"function isSupportedCurrency(c, supported) { return typeof c === 'string' && supported.map(s => s.toLowerCase()).includes(c.toLowerCase()); }","tryCatchPattern":"try {\n  rows = await runCli('coingecko', 'global', ['--currency', cur]);\n} catch (e) {\n  if (e instanceof ArgumentError || /no market totals/.test(e.message)) {\n    console.warn(`${cur} unsupported — falling back to usd`);\n    rows = await runCli('coingecko', 'global', ['--currency', 'usd']);\n  } else throw e;\n}","preventionTips":["Validate currency codes against /simple/supported_vs_currencies","Normalize user input: trim + lowercase before passing","Default to usd and convert locally for exotic currencies","Never interpolate locale-formatted currency strings ('USD-US', '$') into the arg"],"tags":["validation","argument-error","currency","coingecko"],"backgroundTag":"unsupported-currency","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}