jackwener/OpenCLI · error · ArgumentError

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

Error message

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

What it means

requireBoundedInt enforces an upper bound (maxValue) on numeric options like --limit; values above the cap are rejected so a single request cannot hammer the OSV API. The error message includes the exact maximum.

Source

Thrown at clis/osv/utils.js:81

        );
    }
    if (!OSV_ECOSYSTEMS.has(s)) {
        throw new ArgumentError(
            `osv --ecosystem "${value}" is not a recognised OSV ecosystem`,
            `Pick one of: ${[...OSV_ECOSYSTEMS].join(', ')}.`,
        );
    }
    return s;
}

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(`osv ${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`osv ${label} must be <= ${maxValue}`);
    }
    return n;
}

async function readJson(resp, label) {
    let body;
    try {
        body = await resp.json();
    }
    catch (err) {
        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
    }
    return body;
}

export async function osvGet(url, label) {
    let resp;
    try {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the error message for the exact cap and lower your value (e.g. --limit 100).
  2. Paginate: issue multiple queries instead of one oversized limit.
  3. Clamp the value in your wrapper: Math.min(userLimit, MAX).
  4. Check the command docs for the supported maxValue.

Example fix

// before
osvQuery({ limit: 5000 });
// after
osvQuery({ limit: Math.min(5000, 1000) });
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

const isWithinLimit = (v, max) =>
  Number.isInteger(Number(v)) && Number(v) > 0 && Number(v) <= max;

Try / catch

try {
  const result = await osvQuery({ limit });
} catch (e) {
  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {
    console.error(`Lower --limit (max shown in message) or paginate instead`);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing --limit with a value greater than the command's maximum (e.g. --limit 10000 when max is 100 or 1000), often from config or a 'fetch everything' mindset.

Common situations: Setting a very large limit in CI config; confusing page size with total count; copying a limit from another tool with different bounds.

Related errors


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