{"record":{"id":"54474a1ee46e7fbb","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-c-54474a","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}. Check that lichess.org is reachable from this network.","messagePattern":"(.+?) request failed: (.+?)\\. Check that lichess\\.org is reachable from this network\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/lichess/utils.js","lineNumber":64,"sourceCode":"export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`lichess ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`lichess ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport async function lichessFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that lichess.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `Lichess returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'Lichess throttles anonymous traffic at ~60 req/min; back off and retry.',\n        );\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);\n    }\n    let body;\n    try {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lichess/utils.js#L46-L82","documentation":"This CommandExecutionError wraps a network-level failure of the HTTP request to lichess.org inside `lichessFetch`. The `fetch` call itself threw (DNS failure, connection refused, TLS error, timeout), so the library rethrows with the label and a reachability hint.","triggerScenarios":"Any command routed through `lichessFetch` when `fetch(url)` rejects: no network connection, DNS resolution failure, firewall/proxy blocking lichess.org, TLS interception, or a request timeout.","commonSituations":"Working offline or on a captive-portal Wi-Fi; corporate proxy blocking the domain; DNS misconfiguration; VPN dropping; transient ISP outage; IPv6 issues reaching lichess.org.","solutions":["Check general connectivity, then `curl -I https://lichess.org/api` to test reachability","Read the underlying `err.message` in the error text to identify DNS vs connection vs TLS issues","Configure proxy/HTTPS_PROXY environment variables if behind a corporate proxy","Retry with backoff if it was a transient network blip","Fix DNS settings or switch networks if resolution is failing"],"exampleFix":"// before\nawait lichessFetch(url, label); // throws on any network hiccup\n// after\nimport pRetry from 'p-retry';\nconst resp = await pRetry(() => lichessFetch(url, label), { retries: 3, minTimeout: 500 });","handlingStrategy":"retry","validationCode":"// Pre-flight reachability check before batch runs\nasync function lichessReachable() {\n  try { const r = await fetch('https://lichess.org/api'); return r.ok || r.status < 500; }\n  catch { return false; }\n}\nif (!(await lichessReachable())) throw new Error('lichess.org unreachable — check network/proxy');","typeGuard":null,"tryCatchPattern":"import pRetry from 'p-retry';\ntry {\n  const data = await pRetry(() => body(url, label), {\n    retries: 3,\n    onFailedAttempt: e => console.warn(`attempt ${e.attemptNumber} failed: ${e.message}`),\n  });\n} catch (e) {\n  console.error(`Cannot reach lichess.org: ${e.message}. Check network, DNS, and HTTPS_PROXY.`);\n  process.exitCode = 1;\n}","preventionTips":["Verify connectivity/DNS (curl https://lichess.org/api) before batch jobs","Set HTTPS_PROXY/HTTP_PROXY correctly on corporate networks","Add retry-with-backoff for transient network failures","Fail fast with a pre-flight check in scripts and CI"],"tags":["network","fetch","lichess","connectivity"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}