jackwener/OpenCLI · error · CommandExecutionError
coingecko returned error: ${data.error}
Error message
coingecko returned error: ${data.error} What it means
This CommandExecutionError is thrown when the parsed JSON body contains a truthy `error` field. CoinGecko sometimes signals API-level failures inside a 200/JSON body (e.g. status/error objects for invalid parameters or plan restrictions), and this branch surfaces that embedded error message directly to the caller.
Source
Thrown at clis/coingecko/coin.js:69
throw new CommandExecutionError(`coingecko coin request failed: ${error?.message || error}`);
}
if (resp.status === 404) {
throw new EmptyResultError('coingecko coin', `coingecko has no coin with id "${id}".`);
}
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 coin failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);
}
if (data?.error) {
throw new CommandExecutionError(`coingecko returned error: ${data.error}`);
}
const md = data.market_data || {};
const pick = (obj, key) => (obj && obj[key] != null ? obj[key] : null);
const isoFromMaybe = (s) => (s ? String(s).slice(0, 10) : '');
const price = pick(md.current_price, currency);
const marketCap = pick(md.market_cap, currency);
const volume24h = pick(md.total_volume, currency);
if (price == null && marketCap == null && volume24h == null) {
throw new CommandExecutionError(
`coingecko returned no market data for currency "${currency}"`,
'Use a CoinGecko-supported quote currency such as usd, cny, eur, or jpy.',
);
}
return [{
id: data.id || id,
symbol: String(data.symbol || '').toUpperCase(),View on GitHub (pinned to 49907e53dc)
Solutions
- Read the embedded error text in the message — it usually names the exact API-side problem
- Retry after a delay if it looks transient (CoinGecko internal error)
- Verify the command/parameters against current CoinGecko API v3 docs in case the endpoint contract changed
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
const hasEmbeddedApiError = (data) => data != null && typeof data === 'object' && 'error' in data && data.error != null;
Try / catch
try { const rows = await run(['coingecko', 'coin', id]); } catch (e) { if (/coingecko returned error:/.test(e.message)) { console.error('API-side error:', e.message); return retryLaterIfTransient(e); } throw e; } Prevention
- Surface the embedded error text to diagnose plan/endpoint restrictions
- Keep the CLI and its endpoint usage aligned with current CoinGecko v3 docs
- Retry with backoff only for transient-looking errors; escalate persistent ones
When it happens
Trigger: CoinGecko responding with JSON containing an `error` key — e.g. internal API errors, plan/endpoint restrictions, or deprecated-parameter responses wrapped in a 2xx status.
Common situations: Endpoint behavior changes or plan gating on CoinGecko's side; hitting an endpoint variant with different auth requirements; transient CoinGecko internal errors returned in-body.
Related errors
- coingecko returned error: ${data.error}
- ${probe.detail}
- Bilibili ${label} API returned a malformed payload
- Bilibili ${label} API failed: ${message} (${payload.code})
- Bilibili ${label} API returned malformed data
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6b4480ecd7f6bb36.
Report an issue: GitHub.