jackwener/OpenCLI · error · ArgumentError
event must be an event id, an /events/:id URL, a stats URL w
Error message
event must be an event id, an /events/:id URL, a stats URL with event=, or all
What it means
parseEventRef throws this when the input matches none of the supported event reference formats: a bare numeric id, an /events/:id/... URL, or a stats URL with a numeric event= query parameter. The message enumerates every accepted shape.
Source
Thrown at clis/hltv/utils.js:154
export function parseEventRef(value) {
const raw = String(value ?? '').trim();
if (!raw || raw === 'all') return null;
if (/^\d+$/.test(raw)) return raw;
let url = null;
if (/^https?:\/\//i.test(raw)) url = parseHltvUserUrl(raw, 'event');
if (url?.searchParams.get('event')) {
const eventId = url.searchParams.get('event');
if (/^\d+$/.test(eventId)) return eventId;
throw new ArgumentError('event query parameter must be a numeric event id');
}
const path = (url ? url.pathname : raw).replace(/^\/+/, '');
const eventPath = path.match(/^events\/(\d+)\//i);
if (eventPath) return eventPath[1];
throw new ArgumentError('event must be an event id, an /events/:id URL, a stats URL with event=, or all');
}
export function parseTeamRef(value, defaultValue = null) {
const raw = String(value ?? defaultValue ?? '').trim();
if (!raw) throw new ArgumentError('team is required');
let path = raw;
if (/^https?:\/\//i.test(raw)) path = parseHltvUserUrl(raw, 'team').pathname;
path = path.replace(/^https?:\/\/[^/]+/i, '').replace(/^\/+/, '');
const statsMatch = path.match(/^stats\/teams(?:\/matches)?\/(\d+)\/([a-z0-9-]+)/i);
const teamMatch = path.match(/^team\/(\d+)\/([a-z0-9-]+)/i);
const compactMatch = path.match(/^(\d+)\/([a-z0-9-]+)$/i);
const match = statsMatch || teamMatch || compactMatch;
if (!match) {
throw new ArgumentError('team must be like 6667/falcons, a team URL, or a stats team URL');
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Convert the input to the numeric event id found in the event page URL (/events/7148/iem-katowice-2024)
- Use the exact event URL copied from the HLTV event page
- Or use the stats URL containing ?event=<numeric id>
- Use 'all' if the command supports it and you want to omit the event filter
Example fix
// before --event iem-katowice-2024 // after --event 7148
Defensive patterns
Strategy: validation
Validate before calling
const isValidEventRef = (v) => /^\d+$/.test(String(v)) || /^https?:\/\/(www\.)?hltv\.org\/events\/\d+\//i.test(String(v)) || /^https?:\/\/[^?]*\??.*event=\d+/.test(String(v)) || v === 'all';
Type guard
const isEventRef = (v) => ['string','number'].includes(typeof v) && isValidEventRef(String(v));
Try / catch
try {
await hltv.matches({ event: ref });
} catch (e) {
if (e.name === 'ArgumentError' && e.message.includes('event must be an event id')) {
console.error('Use a numeric id, /events/:id URL, stats URL with event=, or "all"');
} else throw e;
} Prevention
- Resolve event names to ids before invoking the command
- Keep a lookup table of event ids in your scripts
- Default to 'all' when no specific event is needed
When it happens
Trigger: Passing an event slug/name like 'iem-katowice-2024', a non-HLTV URL, a /events/:id URL missing the numeric id, or an empty/garbage string.
Common situations: Users typing event names instead of ids; copying results-page URLs that are not /events/:id; old scripts using a URL format the parser never supported.
Related errors
- event query parameter must be a numeric event id
- team must be like 6667/falcons, a team URL, or a stats team
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d1db010d54408b89.
Report an issue: GitHub.