jackwener/OpenCLI · error · ArgumentError

steam ${label} must be <= ${maxValue}

Error message

steam ${label} must be <= ${maxValue}

What it means

After the positivity check, requireBoundedInt enforces an upper bound: values greater than maxValue throw ArgumentError stating the limit. This keeps result-set sizes (and API load) bounded.

Source

Thrown at clis/steam/utils.js:35

    const raw = value === undefined || value === null ? defaultValue : value;
    const code = String(raw).trim().toLowerCase();
    if (!/^[a-z]{2}$/.test(code)) {
        throw new ArgumentError(
            `steam currency must be a two-letter storefront country code (got "${value}")`,
            'Examples: us, cn, jp, de. This controls Steam regional pricing and availability.',
        );
    }
    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;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reduce the value to <= the stated maximum (see the error message for maxValue)
  2. Omit the flag to use the default limit
  3. Check the command's help text for the allowed range
  4. Catch ArgumentError and clamp: n = Math.min(requested, maxValue)

Example fix

// before
--limit 100
// after
--limit 50
Defensive patterns

Strategy: validation

Validate before calling

const MAX = 50;
const n = Number(raw);
if (Number.isInteger(n) && n > MAX) throw new Error(`limit must be <= ${MAX}`);

Type guard

function isWithinLimit(v, max) {
  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;
}

Try / catch

try {
  await cmd({ limit: n });
} catch (e) {
  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {
    const max = Number(e.message.match(/<= (\d+)/)?.[1] ?? 50);
    return cmd({ limit: Math.min(n, max) }); // clamp and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a limit larger than the command's maximum (e.g. --limit 100 when maxValue is 50).

Common situations: Users assuming 'no cap' and passing huge numbers; scripts copying limits from other CLIs with different bounds; confusion between page size and total results.

Related errors


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