jackwener/OpenCLI · error · ArgumentError
lichess perf is required (e.g. "blitz", "bullet", "rapid")
Error message
lichess perf is required (e.g. "blitz", "bullet", "rapid")
What it means
This ArgumentError is thrown by `requirePerf` when the perf (rating category) argument is empty or missing. The library needs an explicit perf such as 'blitz', 'bullet', or 'rapid' to select the rating to show.
Source
Thrown at clis/lichess/utils.js:36
'chess960', 'crazyhouse', 'antichess', 'atomic', 'horde',
'kingOfTheHill', 'racingKings', 'threeCheck',
]);
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}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Supply a valid perf name, e.g. 'blitz', 'bullet', 'rapid', 'classical'
- Check the command's --help for the accepted perf list
- Fix the empty config/env value feeding the argument
- Default the value in your wrapper before calling, e.g. `perfArg ?? 'blitz'`
Example fix
// before
await perf('drnik', ''); // ArgumentError: lichess perf is required
// after
await perf('drnik', process.env.PERF ?? 'blitz'); Defensive patterns
Strategy: validation
Validate before calling
const PERFS = new Set(['ultraBullet','bullet','blitz','rapid','classical','correspondence','chess960','crazyhouse','antichess','atomic','horde','kingOfTheHill','racingKings','threeCheck']);
function assertPerf(v) {
const s = String(v ?? '').trim();
if (!s) throw new TypeError('perf is required (e.g. "blitz", "bullet", "rapid")');
return s;
}
assertPerf(opts.perf); Type guard
function hasPerf(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await perf(userArg, perfArg);
} catch (e) {
if (e instanceof ArgumentError && /perf is required/.test(e.message)) {
console.error('Usage: lichess perf <username> <perf> e.g. lichess perf drnik blitz');
process.exitCode = 2;
} else throw e;
} Prevention
- Always supply the perf argument explicitly; there is no implicit default
- Provide a default in your wrapper (`perfArg ?? 'blitz'`) if appropriate
- Check --help for the exact accepted perf values
- Validate CLI flags before invoking the command
When it happens
Trigger: Calling `perf()` (via `requirePerf`) with `undefined`, `null`, `''`, or a whitespace-only value for the perf parameter.
Common situations: Omitting the perf positional/flag on the CLI; a config value defaulting to empty; scripting with an unset variable; assuming a default perf exists when none does.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- lichess username is required
- <train-no> must not be empty
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/831073d5c7f19f93.
Report an issue: GitHub.