jackwener/OpenCLI · warning · EmptyResultError
coingecko returned no trending coins.
Error message
coingecko returned no trending coins.
What it means
This EmptyResultError is thrown when the CoinGecko trending response parses successfully but data.coins is missing, not an array, or an empty array. The library defensively defaults a non-array coins field to [] and then signals 'no trending coins' as a command-level empty result. It means CoinGecko answered 200 with a shape that contains no trending entries.
Source
Thrown at clis/coingecko/trending.js:40
resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
} catch (error) {
throw new CommandExecutionError(`coingecko trending request failed: ${error?.message || error}`);
}
if (resp.status === 429) {
throw new CommandExecutionError('coingecko returned HTTP 429 (rate limited)', 'Wait and retry.');
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko trending failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);
}
const coins = Array.isArray(data?.coins) ? data.coins : [];
if (coins.length === 0) {
throw new EmptyResultError('coingecko trending', 'coingecko returned no trending coins.');
}
return coins.map((entry, i) => {
const c = entry?.item || {};
return {
rank: i + 1,
id: c.id || '',
symbol: String(c.symbol || '').toUpperCase(),
name: c.name || '',
marketCapRank: c.market_cap_rank ?? null,
priceBtc: c.price_btc ?? null,
thumb: c.thumb || c.small || c.large || '',
};
});
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command to rule out a transient empty response
- Log/inspect the raw response body to confirm the current schema still has data.coins as a non-empty array
- If the schema changed, pin/report the library version and check for updates that track the new CoinGecko response shape
- Fallback to a different CoinGecko endpoint (e.g. /search or /coins/markets sorted by volume) if trending stays empty
Example fix
null
Defensive patterns
Strategy: fallback
Validate before calling
null
Type guard
function hasTrendingCoins(d) {
return d && Array.isArray(d.coins) && d.coins.length > 0 && d.coins[0]?.item?.id;
} Try / catch
try {
const trending = await runCli('coingecko trending');
} catch (e) {
if (/returned no trending coins/.test(e.message)) {
return runCli('coingecko top'); // fallback to markets data
}
throw e;
} Prevention
- Log the raw response body when empty to detect CoinGecko schema changes
- Pin library versions and update when CoinGecko changes the trending schema
- Have a fallback data source (markets endpoint sorted by volume)
- Treat empty trending as transient; retry once before falling back
When it happens
Trigger: Calling `coingecko trending` when CoinGecko returns 200 with data.coins === [] or an unexpected payload shape (e.g. an error object without a coins field, or an API schema change where trending coins moved to a different key). `Array.isArray(data?.coins) ? data.coins : []` yields length 0, triggering the throw.
Common situations: CoinGecko quietly changing the trending response schema (coins renamed/nested differently), a degraded/empty response during API incidents, or a proxy/cached response returning an empty JSON object {}.
Related errors
- coingecko top
- CoinGecko returned no category data.
- coingecko derivatives
- coingecko trending failed: HTTP ${resp.status}
- No prices returned for train_no=${trainNo} ${fromStation.nam
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c6fdea15e8c5a52a.
Report an issue: GitHub.