{"record":{"id":"b634ddabd0e48a47","repo":"jackwener/OpenCLI","slug":"team-is-required","errorCode":null,"errorMessage":"team is required","messagePattern":"team is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":159,"sourceCode":"\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\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();","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L141-L177","documentation":"parseTeamRef requires a team reference — either 'id/slug' (6667/falcons), an hltv.org /team/:id/:slug URL, or a stats /stats/teams/:id/:slug URL. It throws this immediately when the resolved value is an empty string after trimming, i.e. no team was supplied and no default applied.","triggerScenarios":"Calling a command with --team '' or omitting --team on a subcommand where it is mandatory; a script variable holding the team is unset.","commonSituations":"Missing CLI flag; empty environment variable interpolated into the command; config file with team: \"\"; refactor removed the hardcoded default.","solutions":["Supply a team reference such as --team 6667/falcons","Use a full team URL like https://www.hltv.org/team/6667/falcons or the stats variant","Check that the script/config actually populates the team value"],"exampleFix":"// before\nhltv team-matches   # --team missing\n// after\nhltv team-matches --team 6667/falcons","handlingStrategy":"validation","validationCode":"if (!opts.team || !String(opts.team).trim()) throw new Error('--team is required, e.g. 6667/falcons');","typeGuard":"const hasTeamRef = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await hltv.teamMatches({ team: cfg.team });\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message === 'team is required') {\n    console.error('Set --team or TEAM env var');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Fail fast in scripts when the team config variable is empty","Provide sensible defaults in config files","Require the flag in your wrapper script before invoking the CLI"],"tags":["cli","validation","missing-argument","argument-error"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}