jackwener/OpenCLI · error · ArgumentError
Invalid Chess.com game URL: "${value}" Expected https://www.
Error message
Invalid Chess.com game URL: "${value}" Expected https://www.chess.com/game/live/<id> or https://www.chess.com/game/daily/<id>. What it means
An ArgumentError thrown by parseGameUrl when the provided string does not match GAME_URL_RE: ^https:\/\/www\.chess\.com\/game\/(live|daily)\/(\d+). The regex captures the game kind (live or daily) and the numeric game id; anything else is rejected before an API call is made.
Source
Thrown at clis/chess/utils.js:35
function isOptionalPlainObject(value) {
return value === undefined || value === null || isPlainObject(value);
}
export function validateUsername(value) {
const s = String(value ?? '').trim().toLowerCase();
if (!s) throw new ArgumentError('<username> is required');
if (!USERNAME_RE.test(s)) {
throw new ArgumentError(`Invalid Chess.com username "${value}"`, 'Usernames are 3-25 chars: a-z, 0-9, hyphen, underscore.');
}
return s;
}
export function parseGameUrl(value) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError('<game-url> is required');
const m = s.match(GAME_URL_RE);
if (!m) {
throw new ArgumentError(
`Invalid Chess.com game URL: "${value}"`,
'Expected https://www.chess.com/game/live/<id> or https://www.chess.com/game/daily/<id>.',
);
}
return { kind: m[1].toLowerCase(), id: m[2] };
}
export async function chessApi(path, fetchImpl = fetch) {
const url = path.startsWith('http') ? path : `${API_BASE}${path}`;
let resp;
try {
resp = await fetchImpl(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} catch (error) {
throw new CommandExecutionError(`Failed to fetch Chess.com API ${url}: ${error?.message || error}`);
}
if (!resp || typeof resp !== 'object') {
throw new CommandExecutionError(`Chess.com API returned an invalid response object for ${url}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Copy the URL directly from an individual game page: https://www.chess.com/game/live/<id> or https://www.chess.com/game/daily/<id>.
- Strip any trailing garbage (quotes, query fragments copied along with the link).
- If you have a games-list or archive URL, open the game first and copy its canonical URL.
- If Chess.com added new game-path variants, extend GAME_URL_RE in clis/chess/utils.js:11.
Example fix
// before
parseGameUrl('https://www.chess.com/games/view/12345'); // throws
// after
parseGameUrl('https://www.chess.com/game/live/12345'); Defensive patterns
Strategy: validation
Validate before calling
const GAME_URL_RE = /^https:\/\/www\.chess\.com\/game\/(live|daily)\/(\d+)/i;
function isValidGameUrl(v) {
return typeof v === 'string' && GAME_URL_RE.test(v.trim());
} Type guard
function parseGameUrlSafe(v) {
const m = typeof v === 'string' ? v.trim().match(/^https:\/\/www\.chess\.com\/game\/(live|daily)\/(\d+)/i) : null;
return m ? { kind: m[1].toLowerCase(), id: m[2] } : null;
} Try / catch
try {
const { kind, id } = parseGameUrl(gameUrl);
} catch (e) {
if (e.name === 'ArgumentError') {
console.error('Expected https://www.chess.com/game/live/<id> or .../game/daily/<id>');
} else throw e;
} Prevention
- Copy the URL from the individual game page, not the games list.
- Pre-validate URLs with the same regex before calling.
- Strip trailing text/quotes when pasting from chat or docs.
When it happens
Trigger: Passing a chess.com/games/ URL, a mobile share link, an empty-id URL like /game/live/, an http:// (non-https) URL, a URL without the numeric id, or a Study/Puzzle URL.
Common situations: Copying the URL from the games archive list page (different path); using a shortened or localized-domain link; pasting a URL that includes trailing text the regex cannot anchor; Chess.com introducing new game types (e.g. /game/live/ vs newer variants) not covered by the regex.
Related errors
- '${rawInput}' does not look like an autohome series id (a nu
- bilibili follow target must be a valid space.bilibili.com/<u
- chatgpt project commands require a chatgpt.com project id or
- Invalid Chess.com username "${value}" Usernames are 3-25 cha
- event query parameter must be a numeric event id
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9808a2c7070d457e.
Report an issue: GitHub.