{"record":{"id":"d1db010d54408b89","repo":"jackwener/OpenCLI","slug":"event-must-be-an-event-id-an-events-id-url-a-s","errorCode":null,"errorMessage":"event must be an event id, an /events/:id URL, a stats URL with event=, or all","messagePattern":"event must be an event id, an /events/:id URL, a stats URL with event=, or all","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":154,"sourceCode":"\nexport function parseEventRef(value) {\n  const raw = String(value ?? '').trim();\n  if (!raw || raw === 'all') return null;\n  if (/^\\d+$/.test(raw)) return raw;\n\n  let url = null;\n  if (/^https?:\\/\\//i.test(raw)) url = parseHltvUserUrl(raw, 'event');\n  if (url?.searchParams.get('event')) {\n    const eventId = url.searchParams.get('event');\n    if (/^\\d+$/.test(eventId)) return eventId;\n    throw new ArgumentError('event query parameter must be a numeric event id');\n  }\n\n  const path = (url ? url.pathname : raw).replace(/^\\/+/, '');\n  const eventPath = path.match(/^events\\/(\\d+)\\//i);\n  if (eventPath) return eventPath[1];\n\n  throw new ArgumentError('event must be an event id, an /events/:id URL, a stats URL with event=, or all');\n}\n\nexport function parseTeamRef(value, defaultValue = null) {\n  const raw = String(value ?? defaultValue ?? '').trim();\n  if (!raw) throw new ArgumentError('team is required');\n\n  let path = raw;\n  if (/^https?:\\/\\//i.test(raw)) path = parseHltvUserUrl(raw, 'team').pathname;\n  path = path.replace(/^https?:\\/\\/[^/]+/i, '').replace(/^\\/+/, '');\n\n  const statsMatch = path.match(/^stats\\/teams(?:\\/matches)?\\/(\\d+)\\/([a-z0-9-]+)/i);\n  const teamMatch = path.match(/^team\\/(\\d+)\\/([a-z0-9-]+)/i);\n  const compactMatch = path.match(/^(\\d+)\\/([a-z0-9-]+)$/i);\n  const match = statsMatch || teamMatch || compactMatch;\n  if (!match) {\n    throw new ArgumentError('team must be like 6667/falcons, a team URL, or a stats team URL');\n  }\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L136-L172","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n--event iem-katowice-2024\n// after\n--event 7148","handlingStrategy":"validation","validationCode":"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';","typeGuard":"const isEventRef = (v) => ['string','number'].includes(typeof v) && isValidEventRef(String(v));","tryCatchPattern":"try {\n  await hltv.matches({ event: ref });\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message.includes('event must be an event id')) {\n    console.error('Use a numeric id, /events/:id URL, stats URL with event=, or \"all\"');\n  } else throw e;\n}","preventionTips":["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"],"tags":["cli","validation","url-parsing","argument-error"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}