jackwener/OpenCLI · warning · EmptyResultError

lichess top: Lichess returned no leaderboard rows for perf "

Error message

lichess top: Lichess returned no leaderboard rows for perf "${perf}".

What it means

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.

Source

Thrown at clis/lichess/top.js:29

    name: 'top',
    access: 'read',
    description: 'Top-N Lichess leaderboard for a perf type (bullet/blitz/rapid/classical/...)',
    domain: 'lichess.org',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'perf', positional: true, required: true, help: 'Perf type (bullet, blitz, rapid, classical, ultraBullet, chess960, ...)' },
        { name: 'limit', type: 'int', default: 10, help: 'Top-N rows (1-200)' },
    ],
    columns: ['rank', 'username', 'id', 'title', 'rating', 'progress', 'patron', 'url'],
    func: async (args) => {
        const perf = requirePerf(args.perf);
        const limit = requireBoundedInt(args.limit, 10, 200);
        const url = `${LICHESS_BASE}/api/player/top/${limit}/${encodeURIComponent(perf)}`;
        const body = await lichessFetch(url, 'lichess top');
        const list = Array.isArray(body?.users) ? body.users : [];
        if (!list.length) {
            throw new EmptyResultError('lichess top', `Lichess returned no leaderboard rows for perf "${perf}".`);
        }
        return list.slice(0, limit).map((u, i) => {
            const username = typeof u?.username === 'string' ? u.username : '';
            const perfBlock = u?.perfs && typeof u.perfs === 'object' ? u.perfs[perf] ?? {} : {};
            return {
                rank: i + 1,
                username,
                id: typeof u?.id === 'string' ? u.id : null,
                title: typeof u?.title === 'string' ? u.title : null,
                rating: typeof perfBlock.rating === 'number' ? perfBlock.rating : null,
                progress: typeof perfBlock.progress === 'number' ? perfBlock.progress : null,
                patron: u?.patron === true,
                url: username ? `${LICHESS_BASE}/@/${encodeURIComponent(username)}/perf/${encodeURIComponent(perf)}` : '',
            };
        });
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use a popular perf type (bullet, blitz, rapid, classical) to confirm the API works
  2. Verify the perf name against Lichess /api/player/top/<limit>/<perf> in a browser
  3. Reduce or adjust the limit if a boundary value yields an empty page
  4. Retry later if Lichess is having API issues

Example fix

// before
await lichessTop('puzzle-race');
// after
await lichessTop('blitz'); // valid perf with populated leaderboard
Defensive patterns

Strategy: retry

Validate before calling

const VALID_PERFS = ['bullet','blitz','rapid','classical','ultraBullet','crazyhouse','antichess','atomic','horde','kingOfTheHill','racingKings','threeCheck'];
if (!VALID_PERFS.includes(perf)) throw new Error(`unknown perf: ${perf}`);

Type guard

const hasLeaderboard = (body) => Array.isArray(body?.users) && body.users.length > 0;

Try / catch

try {
  await lichessTop(perf);
} catch (e) {
  if (e.name === 'EmptyResultError') {
    // fall back to a popular perf or retry after delay
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8d5f335f381592cc. Report an issue: GitHub.