jackwener/OpenCLI · error · ArgumentError

lichess perf "${value}" is not recognised. Allowed values: $

Error message

lichess perf "${value}" is not recognised. Allowed values: ${[...LICHESS_PERFS].join(', ')}.

What it means

This ArgumentError is thrown by `requirePerf` when the perf value is non-empty but not in the `LICHESS_PERFS` allow-list. The library only accepts recognized Lichess rating categories.

Source

Thrown at clis/lichess/utils.js:38

]);

export function requireUsername(value) {
    const raw = String(value ?? '').trim();
    if (!raw) throw new ArgumentError('lichess username is required');
    if (!USERNAME_PATTERN.test(raw)) {
        throw new ArgumentError(
            `lichess username "${value}" is not a valid handle`,
            'Allowed: letters, digits, underscore, dash; length 2-30.',
        );
    }
    return raw;
}

export function requirePerf(value) {
    const raw = String(value ?? '').trim();
    if (!raw) throw new ArgumentError('lichess perf is required (e.g. "blitz", "bullet", "rapid")');
    if (!LICHESS_PERFS.has(raw)) {
        throw new ArgumentError(
            `lichess perf "${value}" is not recognised`,
            `Allowed values: ${[...LICHESS_PERFS].join(', ')}.`,
        );
    }
    return raw;
}

export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
    const raw = value ?? defaultValue;
    const n = typeof raw === 'number' ? raw : Number(raw);
    if (!Number.isInteger(n) || n <= 0) {
        throw new ArgumentError(`lichess ${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`lichess ${label} must be <= ${maxValue}`);
    }
    return n;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use one of the allowed values listed in the error message exactly as shown
  2. Normalize casing to lowercase before calling (e.g. `value.toLowerCase()`)
  3. Check LICHESS_PERFS in clis/lichess/utils.js for the authoritative list
  4. Fix the typo if the intended category exists (e.g. 'blitz' not 'blits')

Example fix

// before
await perf('drnik', 'Rapid'); // not recognised (if set is lowercase)
// after
await perf('drnik', (process.env.PERF ?? 'blitz').toLowerCase());
Defensive patterns

Strategy: validation

Validate before calling

const LICHESS_PERFS = new Set(['ultraBullet','bullet','blitz','rapid','classical','correspondence','chess960','crazyhouse','antichess','atomic','horde','kingOfTheHill','racingKings','threeCheck']);
function normalizePerf(v) {
  const s = String(v ?? '').trim().toLowerCase();
  if (!LICHESS_PERFS.has(s)) throw new TypeError(`unknown perf "${v}"`);
  return s;
}
await perf(userArg, normalizePerf(rawPerf));

Type guard

function isKnownPerf(v) {
  return typeof v === 'string' && LICHESS_PERFS.has(v.trim().toLowerCase());
}

Try / catch

try {
  await perf(userArg, rawPerf);
} catch (e) {
  if (e instanceof ArgumentError && /not recognised/.test(e.message)) {
    console.error(e.message); // includes the allowed values list
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `perf()` (via `requirePerf`) with a misspelled or unsupported perf such as 'blits', 'rapid-fire', 'standard', or 'puzzles' (if not in the set), or wrong casing if the set is lowercase.

Common situations: Typos in the perf name; guessing category names instead of checking the allowed list; using a category from another chess site (e.g. chess.com vocab); uppercase input like 'Blitz' when the set is lowercase.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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