jackwener/OpenCLI · warning · EmptyResultError
coingecko derivatives
Error message
coingecko derivatives
What it means
EmptyResultError raised when the /derivatives endpoint returns valid JSON that is not a non-empty array. The library treats an empty or wrongly-shaped payload as 'no derivative tickers available' and signals it distinctly from a transport failure.
Source
Thrown at clis/coingecko/derivatives.js:60
}
if (resp.status === 429) {
throw new CommandExecutionError(
'coingecko derivatives returned HTTP 429 (rate limited)',
'Free tier allows ~30 calls/min. Wait and retry.',
);
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko derivatives returned HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
}
catch (err) {
throw new CommandExecutionError(`coingecko derivatives returned malformed JSON: ${err?.message ?? err}`);
}
if (!Array.isArray(data) || !data.length) {
throw new EmptyResultError('coingecko derivatives', 'CoinGecko returned no derivative tickers.');
}
let rows = data;
if (filter) {
rows = data.filter((d) => String(d.symbol ?? '').toUpperCase().includes(filter)
|| String(d.index_id ?? '').toUpperCase().includes(filter));
if (!rows.length) {
throw new EmptyResultError('coingecko derivatives', `No derivative tickers matched symbol="${filter}".`);
}
}
return rows.slice(0, limit).map((d, i) => ({
rank: i + 1,
market: String(d.market ?? ''),
symbol: String(d.symbol ?? ''),
indexId: String(d.index_id ?? ''),
contractType: String(d.contract_type ?? ''),
price: d.price != null ? Number(d.price) : null,
change24hPct: d.price_percentage_change_24h != null ? Number(d.price_percentage_change_24h) : null,
fundingRate: d.funding_rate != null ? Number(d.funding_rate) : null,View on GitHub (pinned to 49907e53dc)
Solutions
- Retry shortly — a transient empty payload often resolves.
- Call the endpoint directly (curl) and inspect the JSON shape to confirm whether it is [] or a schema change.
- Check CoinGecko status page / changelog for API schema or endpoint changes.
- Pin to a known-good API version or add a Pro API key for more stable service.
- If schema changed, update the CLI's mapping code to the new response format.
Example fix
// before
const rows = await runCli(['coingecko', 'derivatives']);
// after
try {
const rows = await runCli(['coingecko', 'derivatives']);
} catch (err) {
if (err.name === 'EmptyResultError') {
return []; // treat 'no tickers' as an empty dataset, not a crash
}
throw err;
} Defensive patterns
Strategy: type-guard
Validate before calling
const resp = await fetch('https://api.coingecko.com/api/v3/derivatives');
const data = await resp.json();
if (!Array.isArray(data)) console.warn('Unexpected /derivatives schema:', typeof data, data); Type guard
function hasDerivatives(v) {
return Array.isArray(v) && v.length > 0 && typeof v[0] === 'object' && v[0] !== null && 'symbol' in v[0];
} Try / catch
try {
const rows = await runCli(['coingecko', 'derivatives']);
} catch (err) {
if (err.name === 'EmptyResultError') return []; // empty dataset, not fatal
throw err;
} Prevention
- Treat EmptyResultError as 'no data', distinct from transport errors.
- Pin/monitor the CoinGecko API schema; alert if /derivatives stops returning arrays.
- Cache a last-known-good snapshot as a fallback dataset.
- Check CoinGecko status/changelog when it happens repeatedly.
When it happens
Trigger: API responds 200 with [] (no derivatives listed), or with a non-array JSON value such as {status: {...}} error object, null, or a string — e.g. an undocumented API schema change or a JSON error body that CoinGecko still serves with HTTP 200.
Common situations: CoinGecko quietly changing the /derivatives response shape; an outage page returning a JSON error object with 200; temporarily empty dataset during maintenance; caller parsing a cached/stale proxy response.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- coingecko top
- coingecko returned no trending coins.
- Chess.com returned no stats for ${username}
- CoinGecko returned no category data.
- coingecko returned no market data for currency "${currency}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5293b936e8d8988b.
Report an issue: GitHub.