jackwener/OpenCLI · error · ArgumentError

openreview ${label} must be a positive integer

Error message

openreview ${label} must be a positive integer

What it means

requireBoundedInt is the shared integer validator for OpenReview CLI limit/offset style options. It coerces the value with coerceInt and rejects anything that is not a positive integer (0 and negatives included) before checking the upper bound. This ensures API pagination parameters are always valid positive integers.

Source

Thrown at clis/openreview/utils.js:30

/** Forum / note IDs on OpenReview are short URL-safe slugs (typically 10 chars). */
const ID_PATTERN = /^[A-Za-z0-9_-]{6,20}$/;

/**
 * Coerce a value to a strict integer (accepts numeric strings, rejects
 * floats / non-numeric / NaN). Returns NaN on invalid input so callers can
 * decide on the right typed error.
 */
export function coerceInt(value) {
    if (value === undefined || value === null || value === '') return NaN;
    const n = typeof value === 'number' ? value : Number(value);
    return Number.isFinite(n) && Number.isInteger(n) ? n : NaN;
}

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

export function requireNonNegativeInt(value, defaultValue, label = 'offset') {
    const raw = value ?? defaultValue;
    const n = coerceInt(raw);
    if (!Number.isInteger(n) || n < 0) {
        throw new ArgumentError(`openreview ${label} must be a non-negative integer`);
    }
    return n;
}

export function requireForumId(value, label = 'id') {
    const id = String(value ?? '').trim();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a positive integer, e.g. --limit 25
  2. Omit the flag to use the command's default
  3. Verify the value is not 0, negative, or fractional
  4. Check upstream variables feeding the flag are set and numeric

Example fix

// before
openreview author ~Jane_Doe --limit 0
// after
openreview author ~Jane_Doe --limit 50
Defensive patterns

Strategy: validation

Validate before calling

const n = coerceInt(rawLimit);
if (!Number.isInteger(n) || n <= 0) {
    throw new Error(`limit must be a positive integer, got: ${rawLimit}`);
}

Prevention

When it happens

Trigger: A limit argument (defaulting when undefined, so only when explicitly passed) coerces to a non-integer, 0, or negative number — e.g. --limit abc, --limit 0, --limit -5, --limit 2.5.

Common situations: Typo or accidental characters in the CLI flag value; scripts interpolating empty/unset variables producing strings coerceInt rejects; passing 0 expecting 'unlimited'; locale-formatted numbers like '1,000'.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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