{"record":{"id":"54239ac901ab6f1c","repo":"jackwener/OpenCLI","slug":"chess-com-has-games-archives-for-username-but-n","errorCode":null,"errorMessage":"Chess.com has games archives for ${username} but no games in the most recent ${MAX_ARCHIVE_FETCHES} months","messagePattern":"Chess\\.com has games archives for (.+?) but no games in the most recent (.+?) months","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/chess/games.js","lineNumber":61,"sourceCode":"            throw new EmptyResultError(`Chess.com has no game archives for ${username}`);\n        }\n        const rows = [];\n        for (let i = 0; i < archives.length && i < MAX_ARCHIVE_FETCHES && rows.length < limit; i++) {\n            if (typeof archives[i] !== 'string' || !archives[i].startsWith('https://api.chess.com/pub/player/')) {\n                throw new CommandExecutionError('Chess.com archives payload contains an unexpected archive URL');\n            }\n            const monthly = await chessApi(archives[i]);\n            if (!Array.isArray(monthly.games)) {\n                throw new CommandExecutionError('Chess.com monthly archive payload is missing games array');\n            }\n            const games = monthly.games.slice().reverse();\n            for (const g of games) {\n                rows.push(mapGameRow(g, username));\n                if (rows.length >= limit) break;\n            }\n        }\n        if (rows.length === 0) {\n            throw new EmptyResultError(`Chess.com has games archives for ${username} but no games in the most recent ${MAX_ARCHIVE_FETCHES} months`);\n        }\n        return rows.slice(0, limit);\n    },\n});\n\nexport const __test__ = { parseLimit };\n","sourceCodeStart":43,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chess/games.js#L43-L68","documentation":"The command walks at most MAX_ARCHIVE_FETCHES (6) most recent monthly archives; if archives exist but no games were collected after scanning those months, it throws EmptyResultError. This prevents silently returning zero rows when the player simply hasn't played recently.","triggerScenarios":"A player has archives (older months) but zero games in their 6 most recent archive months — e.g. they stopped playing 7+ months ago, or recent months' archives contain only empty game lists.","commonSituations":"Inactive/dormant accounts; players who only played a few games long ago; requesting games for someone who recently created a new account with games only in old imported archives.","solutions":["If you need older games, fetch archive months beyond the 6-month window directly from https://api.chess.com/pub/player/{u}/games/{yyyy}/{mm}","Confirm the player has actually played recently on chess.com","Catch EmptyResultError and treat as 'no recent games' rather than an error"],"exampleFix":"// before\nawait gamesCommand(username, { limit: 10 }); // throws when player inactive 7+ months\n// after\ntry { await gamesCommand(username, { limit: 10 }); }\ncatch (e) {\n  if (e.name === 'EmptyResultError') return []; // player has no recent games\n  throw e;\n}","handlingStrategy":"fallback","validationCode":"// detect likely dormancy before the call by checking player's last online date\nconst player = await fetch(`https://api.chess.com/pub/player/${encodeURIComponent(username)}`).then(r => r.json());\n// if player.last_online is older than ~6 months, expect no recent games","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await gamesCmd(username, { limit });\n} catch (e) {\n  if (e.name === 'EmptyResultError' && /no games in the most recent/.test(e.message)) return fetchOlderGamesManually(username) ?? [];\n  throw e;\n}","preventionTips":["Check player.last_online before expecting recent games","For players inactive >6 months, fetch older monthly archives directly instead of relying on the 6-month window","Distinguish the two EmptyResultError messages (no archives at all vs no recent games) in your handling code"],"tags":["empty-result","no-data","chess-com","limit"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}