jackwener/OpenCLI · warning · EmptyResultError

CoinGecko returned no category data.

Error message

CoinGecko returned no category data.

What it means

The API call succeeded and parsed, but the data was not a non-empty array, so the CLI throws EmptyResultError('coingecko categories'). This signals a genuinely empty or structurally unexpected payload rather than a transport failure.

Source

Thrown at clis/coingecko/categories.js:63

        }
        if (resp.status === 429) {
            throw new CommandExecutionError(
                'coingecko returned HTTP 429 (rate limited)',
                'Free tier allows ~30 calls/min. Wait and retry.',
            );
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`coingecko categories returned HTTP ${resp.status}`);
        }
        let data;
        try {
            data = await resp.json();
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko categories returned malformed JSON: ${err?.message ?? err}`);
        }
        if (!Array.isArray(data) || !data.length) {
            throw new EmptyResultError('coingecko categories', 'CoinGecko returned no category data.');
        }
        return data.slice(0, limit).map((cat, i) => ({
            rank: i + 1,
            id: String(cat.id ?? ''),
            name: String(cat.name ?? ''),
            marketCap: cat.market_cap != null ? Number(cat.market_cap) : null,
            volume24h: cat.volume_24h != null ? Number(cat.volume_24h) : null,
            marketCapChange24hPct: cat.market_cap_change_24h != null ? Number(cat.market_cap_change_24h) : null,
            top3Coins: Array.isArray(cat.top_3_coins_id) ? cat.top_3_coins_id.join(', ') : '',
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry later — likely a transient upstream data issue
  2. Inspect the raw response body to confirm the payload shape
  3. Update the CLI if CoinGecko changed the categories response format
Defensive patterns

Strategy: fallback

Validate before calling

const data = await (await fetch(url)).json();
if (!Array.isArray(data) || data.length === 0) {
  console.warn('CoinGecko returned no category data; skipping');
}

Type guard

function hasCategoryData(v) {
  return Array.isArray(v) && v.length > 0 && typeof v[0] === 'object' && 'id' in (v[0] ?? {});
}

Try / catch

try {
  table = await runCategories(args);
} catch (err) {
  if (err instanceof EmptyResultError) {
    table = []; // or fall back to cached data
  } else throw err;
}

Prevention

When it happens

Trigger: CoinGecko returns an empty array (no category data) or a non-array JSON object (e.g. an error/status object) from the categories endpoint.

Common situations: CoinGecko API behavior changes returning {status: {...}} error objects with HTTP 200; CoinGecko temporarily having no category data; version drift between the CLI and the API response shape.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/83bec0af8d6516c0. Report an issue: GitHub.