jackwener/OpenCLI · error · ArgumentError

steam app id "${value}" must be a positive integer

Error message

steam app id "${value}" must be a positive integer

What it means

requireAppId validates the Steam app id argument before calling Steam APIs. If the value is non-empty but is not composed entirely of digits, it throws an ArgumentError with a hint on where to find the numeric id. This prevents malformed app ids from being sent to store.steampowered.com.

Source

Thrown at clis/steam/utils.js:46

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}`,
            'Check that store.steampowered.com is reachable from this network.',
        );
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass only the numeric app id, e.g. 620 for Portal 2
  2. Find the id via the steam search command or the URL store.steampowered.com/app/<id>/
  3. Trim whitespace and strip commas/quotes from the value before calling
  4. If using a name, first resolve the name to an id with a Steam search/lookup command

Example fix

// before
requireAppId('https://store.steampowered.com/app/620/Portal_2/')
// after
requireAppId('620')
Defensive patterns

Strategy: validation

Validate before calling

function isValidAppId(v) { const s = String(v ?? '').trim(); return /^\d+$/.test(s); }
if (!isValidAppId(input)) throw new Error('app id must be a positive integer, e.g. 620');

Type guard

function isAppId(v) { return typeof v === 'string' || typeof v === 'number' ? /^\d+$/.test(String(v).trim()) : false; }

Try / catch

try { const id = requireAppId(input); } catch (e) { if (e instanceof ArgumentError) { console.error('Usage: pass a numeric Steam app id, e.g. 620'); } else throw e; }

Prevention

When it happens

Trigger: Calling any command that resolves an app via requireAppId with a value like 'portal 2', '620 ', 'abc123', '620-0', or a pasted URL slug instead of a pure numeric id like '620'.

Common situations: Users paste the game name or the whole store URL instead of the numeric id; scripts pass an empty-then-defaulted value containing letters; copy/paste includes invisible characters or commas (e.g. '1,234'); non-numeric store keys (e.g. 'Dota2Beta') are used.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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