{"record":{"id":"a82fe6a988c1a09e","repo":"jackwener/OpenCLI","slug":"chess-com-returned-no-stats-for-username","errorCode":null,"errorMessage":"Chess.com returned no stats for ${username}","messagePattern":"Chess\\.com returned no stats for (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/chess/stats.js","lineNumber":28,"sourceCode":"\ncli({\n    site: 'chess',\n    name: 'stats',\n    access: 'read',\n    description: 'Chess.com player ratings + win/loss record across game kinds',\n    domain: 'api.chess.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'username', type: 'string', required: true, positional: true, help: 'Chess.com username (case-insensitive)' },\n    ],\n    columns: ['kind', 'rating_current', 'rating_best', 'wins', 'losses', 'draws'],\n    func: async (kwargs) => {\n        const username = validateUsername(kwargs.username);\n        const stats = await chessApi(`/player/${encodeURIComponent(username)}/stats`);\n        const rows = KINDS.map((k) => summarizeStats(stats, k)).filter(Boolean);\n        if (rows.length === 0) {\n            throw new EmptyResultError(`Chess.com returned no stats for ${username}`);\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":10,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chess/stats.js#L10-L33","documentation":"Thrown as an EmptyResultError after the stats command fetches /player/<username>/stats from the Chess.com API and finds no recognizable rating blocks (chess_rapid, chess_blitz, chess_bullet, etc.) to summarize. The call succeeded HTTP-wise, but the payload contained no stats rows for any known time-control kind. It signals an empty result, not a network or auth failure.","triggerScenarios":"Calling chessApi('/player/<username>/stats') succeeds but every summarizeStats(stats, k) returns null because none of the KINDS exist in the response — i.e. the resolved user exists but has never played any rated game tracked in the stats endpoint.","commonSituations":"Querying a brand-new Chess.com account that has only played unrated/casual games; querying a bot or streamer account with stats hidden; a stats payload shape change by Chess.com that renames or removes the chess_* keys.","solutions":["Verify the username has played at least one rated game (check the Chess.com profile page for ratings).","Log the raw stats payload to confirm which chess_* keys the API returned and that they match the KINDS list.","If Chess.com changed the payload shape, update KINDS in clis/chess/stats.js to the new key names.","Treat it as an expected empty result in your caller — catch EmptyResultError and show a friendly 'no stats yet' message."],"exampleFix":"// before\nconst rows = KINDS.map((k) => summarizeStats(stats, k)).filter(Boolean);\nif (rows.length === 0) {\n  throw new EmptyResultError(`Chess.com returned no stats for ${username}`);\n}\n// after\nconst rows = KINDS.map((k) => summarizeStats(stats, k)).filter(Boolean);\nif (rows.length === 0) {\n  console.warn(`No rated games found for ${username}; showing profile only.`);\n  return [];\n}","handlingStrategy":"try-catch","validationCode":"// Nothing to pre-check locally; optionally verify the player has rated games first:\nconst profile = await chessApi(`/player/${encodeURIComponent(username)}`);\nif (!profile || profile.league === undefined && profile.joined === undefined) {\n  console.warn('Player profile looks empty; stats may be empty too.');\n}","typeGuard":"function hasAnyStatsKind(stats, kinds) {\n  return kinds.some((k) => stats && typeof stats === 'object' && stats[k] != null);\n}","tryCatchPattern":"try {\n  const rows = await chessStats({ username });\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    console.log(`No rated stats for ${username} yet.`);\n  } else throw e;\n}","preventionTips":["Confirm the account has played rated games before expecting stats rows.","Catch EmptyResultError specifically and degrade gracefully to a profile-only view.","Keep the KINDS list in sync with Chess.com's chess_* key names."],"tags":["empty-result","chess-com","api-response","no-data"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}