jackwener/OpenCLI · error · ArgumentError

steam app id is required (e.g. "620" for Portal 2)

Error message

steam app id is required (e.g. "620" for Portal 2)

What it means

requireAppId requires a non-empty, all-digit app id; a missing value throws ArgumentError with an example ('620' for Portal 2). A present-but-non-numeric value throws a separate, more detailed error.

Source

Thrown at clis/steam/utils.js:43

    return code;
}

export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
    const raw = value ?? defaultValue;
    const n = typeof raw === 'number' ? raw : Number(raw);
    if (!Number.isInteger(n) || n <= 0) {
        throw new ArgumentError(`steam ${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`steam ${label} must be <= ${maxValue}`);
    }
    return n;
}

export function requireAppId(value) {
    const s = String(value ?? '').trim();
    if (!s) {
        throw new ArgumentError('steam app id is required (e.g. "620" for Portal 2)');
    }
    if (!/^\d+$/.test(s)) {
        throw new ArgumentError(
            `steam app id "${value}" must be a positive integer`,
            'Copy the numeric id from `steam search` or the URL `store.steampowered.com/app/<id>/`.',
        );
    }
    return s;
}

export async function steamFetch(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide the numeric app id, e.g. `steam app 620`
  2. Run `steam search <name>` first to find the id
  3. Extract the id from the store URL store.steampowered.com/app/<id>/
  4. Catch ArgumentError and print usage including the Portal 2 example

Example fix

// before
steam app            // missing id
// after
steam app 620
Defensive patterns

Strategy: validation

Validate before calling

function requireAppIdArg(v) {
  const s = String(v ?? '').trim();
  if (!s) throw new Error('app id required; find it via `steam search` or store.steampowered.com/app/<id>/');
  if (!/^\d+$/.test(s)) throw new Error(`app id must be numeric, got: ${v}`);
  return s;
}

Type guard

function isNumericId(v) {
  return typeof v === 'string' && /^\d+$/.test(v.trim());
}

Try / catch

try {
  await cmd({ id: appId });
} catch (e) {
  if (e instanceof ArgumentError && /app id is required/.test(e.message)) {
    console.error('Usage: steam app <id>  e.g. steam app 620');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `steam app` without an id argument, or with an empty/whitespace value; ids pasted with surrounding text (e.g. 'app/620') go to the second check, not this one.

Common situations: Forgetting the positional id on the command line; shell variables that are unset; programmatic callers passing null/undefined.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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