{"record":{"id":"21eaaf372c380a68","repo":"jackwener/OpenCLI","slug":"failed-to-fetch-chess-com-callback-url-error","errorCode":null,"errorMessage":"Failed to fetch Chess.com callback ${url}: ${error?.message || error}","messagePattern":"Failed to fetch Chess\\.com callback (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chess/game.js","lineNumber":93,"sourceCode":"    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'game-url', type: 'string', required: true, positional: true, help: 'Full game URL, e.g. https://www.chess.com/game/live/168842570216' },\n    ],\n    columns: [\n        'kind', 'game_id', 'date',\n        'white', 'white_rating', 'black', 'black_rating',\n        'result', 'winner_color', 'termination',\n        'eco', 'time_control', 'rated', 'ply_count', 'url',\n    ],\n    func: async (kwargs) => {\n        const { kind, id } = parseGameUrl(kwargs['game-url']);\n        const url = `${CALLBACK_BASE}/${kind}/game/${id}`;\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });\n        } catch (error) {\n            throw new CommandExecutionError(`Failed to fetch Chess.com callback ${url}: ${error?.message || error}`);\n        }\n        if (!resp || typeof resp !== 'object') {\n            throw new CommandExecutionError(`Chess.com callback returned an invalid response object for ${url}`);\n        }\n        if (resp.status === 404) {\n            throw new EmptyResultError(`Chess.com has no ${kind} game with id ${id}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`Chess.com callback returned HTTP ${resp.status} for ${url}`);\n        }\n        let payload;\n        try {\n            payload = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`Chess.com callback returned malformed JSON for ${url}: ${error?.message || error}`);\n        }\n        return [summarizeGame({ kind, id, payload })];\n    },","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chess/game.js#L75-L111","documentation":"The chess game command fetches `${CALLBACK_BASE}/${kind}/game/${id}` from Chess.com's callback API; if the fetch call itself rejects (network layer failure, not an HTTP error status), the error is wrapped in this CommandExecutionError with the URL and original message.","triggerScenarios":"fetch() throws — DNS resolution failure, connection refused/reset, TLS errors, request timeout, or offline machine — when calling the Chess.com callback endpoint for the given game kind/id.","commonSituations":"No internet/VPN required for chess.com; corporate firewall blocking the domain; transient DNS failures; Node without network permissions in sandboxed CI.","solutions":["Check network connectivity and DNS, then retry the command.","Verify the callback URL is reachable (curl the same URL with the same User-Agent/accept headers).","Add retry with backoff around the fetch for transient network errors.","Confirm firewall/proxy rules allow HTTPS to chess.com from the running environment."],"exampleFix":"// before\nresp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });\n// after\ntry {\n  resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });\n} catch (error) {\n  throw new CommandExecutionError(`Failed to fetch Chess.com callback ${url}: ${error?.message || error}`);\n}","handlingStrategy":"retry","validationCode":"const url = `${CALLBACK_BASE}/${kind}/game/${id}`;\nawait fetch(url, { method: 'HEAD' }).catch(() => { throw new Error('Chess.com callback endpoint unreachable'); });","typeGuard":"null","tryCatchPattern":"try {\n  resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });\n} catch (error) {\n  // retry with backoff for transient network errors\n  await sleep(1000);\n  resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });\n}","preventionTips":["Implement retry with exponential backoff around fetch","Check connectivity/DNS before batch runs","Allowlist chess.com in proxies/firewalls for CI environments"],"tags":["network","fetch","chess","http"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}