jackwener/OpenCLI · error · CommandExecutionError

coingecko derivatives returned HTTP ${resp.status}

Error message

coingecko derivatives returned HTTP ${resp.status}

What it means

This CommandExecutionError is thrown when CoinGecko's /derivatives endpoint returns any non-2xx status other than 429 (which is handled separately), e.g. 404, 500, or 502/503 from CoinGecko or an intermediary. It surfaces the raw HTTP status so the caller can react.

Source

Thrown at clis/coingecko/derivatives.js:50

        if (limit > 500) {
            throw new ArgumentError('coingecko derivatives limit must be <= 500');
        }
        const filter = args.symbol == null ? '' : String(args.symbol).trim().toUpperCase();
        let resp;
        try {
            resp = await fetch(ENDPOINT, { headers: { 'User-Agent': 'Mozilla/5.0' } });
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko derivatives request failed: ${err?.message ?? err}`);
        }
        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}".`);
            }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the specific status: 5xx means retry later; 404 suggests the endpoint path changed
  2. Check CoinGecko status page (status.coingecko.com) for incidents
  3. Verify the ENDPOINT URL is still valid per current CoinGecko API docs
  4. Add retry with backoff for transient 5xx/503 responses

Example fix

// before
// assuming endpoint always works
fetch('https://api.coingecko.com/api/v3/derivatives')
// after
// verify path against docs and retry on 5xx
const resp = await fetch(ENDPOINT);
if (resp.status >= 500) await retryWithBackoff(() => fetch(ENDPOINT));
Defensive patterns

Strategy: try-catch

Try / catch

if (!resp.ok) {
  if (resp.status >= 500 || resp.status === 503) {
    // transient: retry with backoff
    resp = await retryWithBackoff(() => fetch(ENDPOINT), { retries: 3 });
  } else {
    throw new CommandExecutionError(`coingecko derivatives returned HTTP ${resp.status}`);
  }
}

Prevention

When it happens

Trigger: CoinGecko server-side errors (5xx), endpoint removed/moved (404), gateway errors from CDN (502/503), or an unexpected 4xx like 401 if the endpoint later requires auth.

Common situations: CoinGecko outages or degraded service, API version/URL changes breaking the ENDPOINT path, CDN incidents, maintenance windows.

Related errors


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