{"record":{"id":"8a3b491b72956d9e","repo":"jackwener/OpenCLI","slug":"coingecko-coin-failed-http-resp-status","errorCode":null,"errorMessage":"coingecko coin failed: HTTP ${resp.status}","messagePattern":"coingecko coin failed: HTTP (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/coin.js","lineNumber":60,"sourceCode":"        url.searchParams.set('market_data', 'true');\n        url.searchParams.set('community_data', 'false');\n        url.searchParams.set('developer_data', 'false');\n        url.searchParams.set('sparkline', 'false');\n\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n        } catch (error) {\n            throw new CommandExecutionError(`coingecko coin request failed: ${error?.message || error}`);\n        }\n        if (resp.status === 404) {\n            throw new EmptyResultError('coingecko coin', `coingecko has no coin with id \"${id}\".`);\n        }\n        if (resp.status === 429) {\n            throw new CommandExecutionError('coingecko returned HTTP 429 (rate limited)', 'Free tier allows ~30 calls/min. Wait and retry.');\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`coingecko coin failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);\n        }\n        if (data?.error) {\n            throw new CommandExecutionError(`coingecko returned error: ${data.error}`);\n        }\n\n        const md = data.market_data || {};\n        const pick = (obj, key) => (obj && obj[key] != null ? obj[key] : null);\n        const isoFromMaybe = (s) => (s ? String(s).slice(0, 10) : '');\n        const price = pick(md.current_price, currency);\n        const marketCap = pick(md.market_cap, currency);\n        const volume24h = pick(md.total_volume, currency);\n        if (price == null && marketCap == null && volume24h == null) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/coin.js#L42-L78","documentation":"This CommandExecutionError is thrown when the CoinGecko API returns a non-OK status other than 404 or 429. Typical statuses include 401 (auth required on pro endpoints), 403 (blocked/forbidden, e.g. Cloudflare block), 5xx (CoinGecko server errors), and 414 (URL too long). The status code is interpolated so the caller can diagnose.","triggerScenarios":"CoinGecko returning 401/403 (IP blocked by Cloudflare, API key misuse), 500/502/503 (server-side outage or maintenance), or any other unexpected status.","commonSituations":"CoinGecko partial outages; the client IP being blocked/flagged by Cloudflare bot protection; hitting a deprecated endpoint; proxy injecting error pages.","solutions":["Check the status code in the message; for 5xx, retry later or check https://status.coingecko.com","For 401/403, verify you're using the public api.coingecko.com endpoint without pro credentials and that your IP isn't blocked","Retry with backoff; if persistent, test `curl -I https://api.coingecko.com/api/v3/ping` to isolate environment vs service issues"],"exampleFix":"// before\nif (!resp.ok) throw new CommandExecutionError(`coingecko coin failed: HTTP ${resp.status}`);\n// after\nif (!resp.ok && resp.status >= 500) { await sleep(retryDelay); resp = await fetch(url, opts); } // then keep the throw for still-failing statuses","handlingStrategy":"try-catch","validationCode":"const ping = await fetch('https://api.coingecko.com/api/v3/ping').then(r => r.status).catch(() => 0);\nif (ping >= 500) console.warn('CoinGecko appears to be having server issues; retry later');","typeGuard":"null","tryCatchPattern":"try { await run(['coingecko', 'coin', id]); } catch (e) { const m = /HTTP (\\d{3})/.exec(e.message); if (m && +m[1] >= 500) { await sleep(5000); return retryOnce(); } throw e; }","preventionTips":["Distinguish 4xx (don't retry) from 5xx (retry with backoff) using the status in the message","Watch https://status.coingecko.com during outages","Check IP/proxy reputation if you see persistent 403s (Cloudflare blocks)"],"tags":["http-error","api-request","server-error"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}