{"record":{"id":"904fe406161f1f2d","repo":"jackwener/OpenCLI","slug":"team-must-be-like-6667-falcons-a-team-url-or-a-s","errorCode":null,"errorMessage":"team must be like 6667/falcons, a team URL, or a stats team URL","messagePattern":"team must be like 6667/falcons, a team URL, or a stats team URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":170,"sourceCode":"  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\n  return { teamId: match[1], slug: match[2].toLowerCase() };\n}\n\nexport function parsePlayerRef(value, defaultValue = '3741/niko') {\n  const raw = String(value ?? defaultValue).trim();\n  if (!raw) throw new ArgumentError('player is required');\n\n  let path = raw;\n  if (/^https?:\\/\\//i.test(raw)) path = parseHltvUserUrl(raw, 'player').pathname;\n  path = path.replace(/^https?:\\/\\/[^/]+/i, '').replace(/^\\/+/, '');\n\n  const statsMatch = path.match(/^stats\\/players(?:\\/matches)?\\/(\\d+)\\/([a-z0-9-]+)/i);\n  const playerMatch = path.match(/^player\\/(\\d+)\\/([a-z0-9-]+)/i);\n  const compactMatch = path.match(/^(\\d+)\\/([a-z0-9-]+)$/i);\n  const match = statsMatch || playerMatch || compactMatch;\n  if (!match) {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L152-L188","documentation":"parseTeamRef throws this when the input is non-empty but does not match any accepted team pattern: compact 'id/slug', /team/:id/:slug path, or /stats/teams(/matches)/:id/:slug path. The message shows the expected formats.","triggerScenarios":"Passing just a slug ('falcons') without the id, a player URL, a bare numeric id without a slug, or a URL from a different site section (e.g. /results/...).","commonSituations":"Users assuming team names work alone; copying a player or match URL instead of a team URL; old bookmarks to renamed team slugs (still fine — id matters) vs URLs from other pages entirely.","solutions":["Provide id/slug together, e.g. --team 6667/falcons","Copy the URL directly from the team's page on hltv.org (must contain /team/<id>/<slug> or /stats/teams/<id>/<slug>)","Confirm you copied a team URL and not a player or match URL"],"exampleFix":"// before\n--team falcons\n// after\n--team 6667/falcons","handlingStrategy":"validation","validationCode":"const isTeamRef = (v) => /^(\\d+\\/[a-z0-9-]+|(https?:\\/\\/)?(www\\.)?hltv\\.org\\/)?(stats\\/)?(stats\\/)?(stats\\/teams(?:\\/matches)?|team)\\/\\d+\\/[a-z0-9-]+/i.test(String(v)) || /^\\d+\\/[a-z0-9-]+$/i.test(String(v));","typeGuard":"const looksLikeTeamRef = (v) => /^\\d+\\/[a-z0-9-]+$/i.test(String(v)) || /hltv\\.org\\/(stats\\/)?teams?/i.test(String(v));","tryCatchPattern":"try {\n  await hltv.teamStats({ team: ref });\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message.includes('team must be like')) {\n    console.error('Use id/slug (6667/falcons) or a team page URL');\n  } else throw e;\n}","preventionTips":["Always include the numeric id with the slug","Copy team URLs from the team page, not search results or other sections","Normalize inputs to the compact id/slug form in your scripts"],"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"}