jackwener/OpenCLI · error · ArgumentError

team must be like 6667/falcons, a team URL, or a stats team

Error message

team must be like 6667/falcons, a team URL, or a stats team URL

What it means

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.

Source

Thrown at clis/hltv/utils.js:170

  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');
  }

  return { teamId: match[1], slug: match[2].toLowerCase() };
}

export function parsePlayerRef(value, defaultValue = '3741/niko') {
  const raw = String(value ?? defaultValue).trim();
  if (!raw) throw new ArgumentError('player is required');

  let path = raw;
  if (/^https?:\/\//i.test(raw)) path = parseHltvUserUrl(raw, 'player').pathname;
  path = path.replace(/^https?:\/\/[^/]+/i, '').replace(/^\/+/, '');

  const statsMatch = path.match(/^stats\/players(?:\/matches)?\/(\d+)\/([a-z0-9-]+)/i);
  const playerMatch = path.match(/^player\/(\d+)\/([a-z0-9-]+)/i);
  const compactMatch = path.match(/^(\d+)\/([a-z0-9-]+)$/i);
  const match = statsMatch || playerMatch || compactMatch;
  if (!match) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide id/slug together, e.g. --team 6667/falcons
  2. Copy the URL directly from the team's page on hltv.org (must contain /team/<id>/<slug> or /stats/teams/<id>/<slug>)
  3. Confirm you copied a team URL and not a player or match URL

Example fix

// before
--team falcons
// after
--team 6667/falcons
Defensive patterns

Strategy: validation

Validate before calling

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));

Type guard

const looksLikeTeamRef = (v) => /^\d+\/[a-z0-9-]+$/i.test(String(v)) || /hltv\.org\/(stats\/)?teams?/i.test(String(v));

Try / catch

try {
  await hltv.teamStats({ team: ref });
} catch (e) {
  if (e.name === 'ArgumentError' && e.message.includes('team must be like')) {
    console.error('Use id/slug (6667/falcons) or a team page URL');
  } else throw e;
}

Prevention

When it happens

Trigger: 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/...).

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/904fe406161f1f2d. Report an issue: GitHub.