jackwener/OpenCLI · error · ArgumentError
openreview ${label} must be a non-negative integer
Error message
openreview ${label} must be a non-negative integer What it means
requireNonNegativeInt validates offset-style options: the value must coerce to an integer >= 0. It is used for pagination offsets, so 0 is allowed but negatives and non-integers are rejected with ArgumentError before any API call.
Source
Thrown at clis/openreview/utils.js:42
}
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();
if (!id) {
throw new ArgumentError(`openreview ${label} is required`);
}
if (!ID_PATTERN.test(id)) {
throw new ArgumentError(`openreview ${label} "${value}" is not a valid forum id (expected 6-20 chars of [A-Za-z0-9_-])`);
}
return id;
}
/** OpenReview profile ids are `~...N` slugs and may include dots, hyphens, and Unicode letters. */
const PROFILE_ID_PATTERN = /^~(?=.*\p{L})[\p{L}\p{M}0-9._-]+\d+$/u;
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer >= 0, e.g. --offset 0
- Clamp computed offsets: Math.max(0, page * pageSize)
- Check the variable/expression feeding the offset for negative or empty values
- Omit the flag to start from offset 0
Example fix
// before const offset = (page - 1) * pageSize; // page=0 -> -25 // after const offset = Math.max(0, (page - 1) * pageSize);
Defensive patterns
Strategy: validation
Validate before calling
const n = coerceInt(rawOffset);
if (!Number.isInteger(n) || n < 0) {
throw new Error(`offset must be a non-negative integer, got: ${rawOffset}`);
} Prevention
- Clamp computed offsets: Math.max(0, page * pageSize)
- Guard pagination loops so the index never goes negative
- Omit --offset for the first page (defaults to 0)
- Validate numeric flags in wrapper scripts before invoking
When it happens
Trigger: An offset argument (or whatever label is passed, default 'offset') coerces to a non-integer or a negative integer — e.g. --offset -10, --offset abc, --offset 1.5.
Common situations: Computing offsets as page*size with page starting at -1 or an unset variable; decrement loops underflowing below zero; string values with stray characters that coerceInt rejects; shell arithmetic producing negative results on the last page.
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
- openreview ${label} must be a positive integer
- openreview ${label} must be <= ${maxValue}
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- bilibili comment ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/db2b20dc6cbd0657.
Report an issue: GitHub.