{"record":{"id":"8d5f335f381592cc","repo":"jackwener/OpenCLI","slug":"lichess-top-lichess-returned-no-leaderboard-rows","errorCode":null,"errorMessage":"lichess top: Lichess returned no leaderboard rows for perf \"${perf}\".","messagePattern":"lichess top: Lichess returned no leaderboard rows for perf \"(.+?)\"\\.","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/lichess/top.js","lineNumber":29,"sourceCode":"    name: 'top',\n    access: 'read',\n    description: 'Top-N Lichess leaderboard for a perf type (bullet/blitz/rapid/classical/...)',\n    domain: 'lichess.org',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'perf', positional: true, required: true, help: 'Perf type (bullet, blitz, rapid, classical, ultraBullet, chess960, ...)' },\n        { name: 'limit', type: 'int', default: 10, help: 'Top-N rows (1-200)' },\n    ],\n    columns: ['rank', 'username', 'id', 'title', 'rating', 'progress', 'patron', 'url'],\n    func: async (args) => {\n        const perf = requirePerf(args.perf);\n        const limit = requireBoundedInt(args.limit, 10, 200);\n        const url = `${LICHESS_BASE}/api/player/top/${limit}/${encodeURIComponent(perf)}`;\n        const body = await lichessFetch(url, 'lichess top');\n        const list = Array.isArray(body?.users) ? body.users : [];\n        if (!list.length) {\n            throw new EmptyResultError('lichess top', `Lichess returned no leaderboard rows for perf \"${perf}\".`);\n        }\n        return list.slice(0, limit).map((u, i) => {\n            const username = typeof u?.username === 'string' ? u.username : '';\n            const perfBlock = u?.perfs && typeof u.perfs === 'object' ? u.perfs[perf] ?? {} : {};\n            return {\n                rank: i + 1,\n                username,\n                id: typeof u?.id === 'string' ? u.id : null,\n                title: typeof u?.title === 'string' ? u.title : null,\n                rating: typeof perfBlock.rating === 'number' ? perfBlock.rating : null,\n                progress: typeof perfBlock.progress === 'number' ? perfBlock.progress : null,\n                patron: u?.patron === true,\n                url: username ? `${LICHESS_BASE}/@/${encodeURIComponent(username)}/perf/${encodeURIComponent(perf)}` : '',\n            };\n        });\n    },\n});\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lichess/top.js#L11-L47","documentation":"lichess top fetches the leaderboard for a perf type and requires a non-empty body.users array. If Lichess responds with no rows (users missing or empty), it throws EmptyResultError naming the perf. This indicates the leaderboard is unavailable/empty for that perf type rather than a transport failure.","triggerScenarios":"Requesting a perf with no rated players (rare/variant perfs like 'threeCheck' or invalid-but-accepted perfs), a limit beyond available players, or Lichess returning an empty users object for that limit/perf combination.","commonSituations":"Niche variants with very few ranked players; typo'd perf name slipping past validation; Lichess API hiccup returning {} without users; asking for top 200 when only a handful exist (only if users array is empty, not short).","solutions":["Use a popular perf type (bullet, blitz, rapid, classical) to confirm the API works","Verify the perf name against Lichess /api/player/top/<limit>/<perf> in a browser","Reduce or adjust the limit if a boundary value yields an empty page","Retry later if Lichess is having API issues"],"exampleFix":"// before\nawait lichessTop('puzzle-race');\n// after\nawait lichessTop('blitz'); // valid perf with populated leaderboard","handlingStrategy":"retry","validationCode":"const VALID_PERFS = ['bullet','blitz','rapid','classical','ultraBullet','crazyhouse','antichess','atomic','horde','kingOfTheHill','racingKings','threeCheck'];\nif (!VALID_PERFS.includes(perf)) throw new Error(`unknown perf: ${perf}`);","typeGuard":"const hasLeaderboard = (body) => Array.isArray(body?.users) && body.users.length > 0;","tryCatchPattern":"try {\n  await lichessTop(perf);\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    // fall back to a popular perf or retry after delay\n  } else throw e;\n}","preventionTips":["Use mainstream perfs (bullet/blitz/rapid/classical) for reliable data","Verify perf names against Lichess API docs","Retry once on empty leaderboards (transient API issues)","Handle sparse variant leaderboards gracefully"],"tags":["empty-result","lichess","leaderboard","api"],"backgroundTag":"empty-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}