jackwener/OpenCLI · error · ArgumentError

${label} must be an hltv.org URL

Error message

${label} must be an hltv.org URL

What it means

parseHltvUserUrl's second check: the raw string parsed as a URL but its hostname is not an hltv.org host (per isHltvHost). The library refuses to scrape non-HLTV URLs and throws this ArgumentError with the parameter label. Raised from parseEventRef, parseTeamRef, parsePlayerRef and the url helper.

Source

Thrown at clis/hltv/utils.js:17

import { ArgumentError, CommandExecutionError, EmptyResultError, TimeoutError } from '@jackwener/opencli/errors';

export const BASE = 'https://www.hltv.org';

function isHltvHost(hostname) {
  return hostname === 'hltv.org' || hostname === 'www.hltv.org';
}

function parseHltvUserUrl(raw, label) {
  let url;
  try {
    url = new URL(raw);
  } catch {
    throw new ArgumentError(`${label} must be a valid hltv.org URL`);
  }
  if (!isHltvHost(url.hostname)) {
    throw new ArgumentError(`${label} must be an hltv.org URL`);
  }
  return url;
}

export const EVENT_TYPES = {
  all: null,
  majors: 'Majors',
  bigEvents: 'BigEvents',
  mvpEvents: 'MvpEvents',
  lan: 'Lan',
  online: 'Online',
};

export const RANKING_FILTERS = {
  all: null,
  top5: 'Top5',
  top10: 'Top10',
  top20: 'Top20',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use an https://www.hltv.org URL (correct domain) for the ref
  2. Check for typos in the domain (hltv.com vs hltv.org)
  3. If using a proxy/mirror, map URLs back to hltv.org before parsing
  4. Catch ArgumentError and validate the hostname with a guard before calling

Example fix

// before
const ref = parseTeamRef('https://www.hltv.com/team/4608/natus-vincere'); // wrong TLD
// after
const ref = parseTeamRef('https://www.hltv.org/team/4608/natus-vincere');
Defensive patterns

Strategy: validation

Validate before calling

function isHltvOrgUrl(raw) {
  try { return new URL(raw).hostname === 'www.hltv.org' || new URL(raw).hostname.endsWith('.hltv.org'); }
  catch { return false; }
}
if (!isHltvOrgUrl(input)) throw new Error('expected an hltv.org URL');

Type guard

function isHltvHostname(u) { try { const url = new URL(u); return /(^|\.)hltv\.org$/.test(url.hostname); } catch { return false; } }

Try / catch

try {
  const ref = parseEventRef(raw);
} catch (err) {
  if (err instanceof ArgumentError && /must be an hltv\.org URL/.test(err.message)) {
    return fail(`wrong host, expected hltv.org: ${new URL(raw).hostname}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing a URL from another site (e.g. liquipedia, bo3.gg), a subdomain not covered by isHltvHost (mirror/typosquat domain), or a crafted URL with an unexpected hostname to any of the ref parsers.

Common situations: Mixing data sources and passing another site's match URL; using hltv.com or a regional mirror instead of hltv.org; environment-specific base URL overrides pointing at a proxy; copy-paste from search results landing on an aggregator.

Related errors


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