{"record":{"id":"cb9fb3cc25fa57d8","repo":"jackwener/OpenCLI","slug":"lichess-perf-value-is-not-recognised-allowed","errorCode":null,"errorMessage":"lichess perf \"${value}\" is not recognised. Allowed values: ${[...LICHESS_PERFS].join(', ')}.","messagePattern":"lichess perf \"(.+?)\" is not recognised\\. Allowed values: (.+?)\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/lichess/utils.js","lineNumber":38,"sourceCode":"]);\n\nexport function requireUsername(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) throw new ArgumentError('lichess username is required');\n    if (!USERNAME_PATTERN.test(raw)) {\n        throw new ArgumentError(\n            `lichess username \"${value}\" is not a valid handle`,\n            'Allowed: letters, digits, underscore, dash; length 2-30.',\n        );\n    }\n    return raw;\n}\n\nexport function requirePerf(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) throw new ArgumentError('lichess perf is required (e.g. \"blitz\", \"bullet\", \"rapid\")');\n    if (!LICHESS_PERFS.has(raw)) {\n        throw new ArgumentError(\n            `lichess perf \"${value}\" is not recognised`,\n            `Allowed values: ${[...LICHESS_PERFS].join(', ')}.`,\n        );\n    }\n    return raw;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`lichess ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`lichess ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lichess/utils.js#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the allowed values listed in the error message exactly as shown","Normalize casing to lowercase before calling (e.g. `value.toLowerCase()`)","Check LICHESS_PERFS in clis/lichess/utils.js for the authoritative list","Fix the typo if the intended category exists (e.g. 'blitz' not 'blits')"],"exampleFix":"// before\nawait perf('drnik', 'Rapid'); // not recognised (if set is lowercase)\n// after\nawait perf('drnik', (process.env.PERF ?? 'blitz').toLowerCase());","handlingStrategy":"validation","validationCode":"const LICHESS_PERFS = new Set(['ultraBullet','bullet','blitz','rapid','classical','correspondence','chess960','crazyhouse','antichess','atomic','horde','kingOfTheHill','racingKings','threeCheck']);\nfunction normalizePerf(v) {\n  const s = String(v ?? '').trim().toLowerCase();\n  if (!LICHESS_PERFS.has(s)) throw new TypeError(`unknown perf \"${v}\"`);\n  return s;\n}\nawait perf(userArg, normalizePerf(rawPerf));","typeGuard":"function isKnownPerf(v) {\n  return typeof v === 'string' && LICHESS_PERFS.has(v.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  await perf(userArg, rawPerf);\n} catch (e) {\n  if (e instanceof ArgumentError && /not recognised/.test(e.message)) {\n    console.error(e.message); // includes the allowed values list\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Copy perf names exactly from the error's allowed-values list","Lowercase and trim user input before passing","Use tab-completion or a fixed enum in your wrapper/UI","Don't borrow category names from other chess sites"],"tags":["lichess","argument-validation","invalid-enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}