jackwener/OpenCLI · error · ArgumentError
indeed ${label} must be a non-negative integer
Error message
indeed ${label} must be a non-negative integer What it means
requireNonNegativeInt validates that an option value is an integer >= 0 (zero allowed, negatives and non-integers rejected). It throws an ArgumentError naming the option via label. It is used for offset-style options like start where 0 is a legitimate value.
Source
Thrown at clis/indeed/utils.js:49
}
export function requireBoundedInt(value, defaultValue, maxValue, label) {
const raw = value ?? defaultValue;
const n = coerceInt(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(`indeed ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`indeed ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireNonNegativeInt(value, defaultValue, label) {
const raw = value ?? defaultValue;
const n = coerceInt(raw);
if (!Number.isInteger(n) || n < 0) {
throw new ArgumentError(`indeed ${label} must be a non-negative integer`);
}
return n;
}
export function requireJobKey(value) {
const id = String(value ?? '').trim().toLowerCase();
if (!id) {
throw new ArgumentError('indeed job id is required');
}
if (!JK_PATTERN.test(id)) {
throw new ArgumentError(`indeed job id "${value}" is not a valid jk (expected 16-char lowercase hex)`);
}
return id;
}
export function requireQuery(value, label = 'query') {
const q = String(value ?? '').trim();
if (!q) {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-negative whole number (start 0 for the first page).
- Fix the pagination counter math in the calling script.
- Omit the option to use the default of 0.
Example fix
// before indeed start -10 // after indeed start 0
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(raw); if (!(Number.isInteger(n) && n > 0 && n <= maxValue)) raw = maxValue;
Type guard
function isWithinBound(v, max) { return Number.isInteger(v) && v > 0 && v <= max; } Try / catch
try { const n = requireBoundedInt(value, def, max, 'limit'); } catch (e) { if (e instanceof ArgumentError && e.message.includes('must be <=')) { console.warn(`Capping limit to ${max}`); return max; } throw e; } Prevention
- Cap batch sizes to documented maxima in automation scripts.
- Paginate instead of raising the limit.
- Consult the CLI help for current caps.
When it happens
Trigger: Calling start with a negative number (`indeed start -10`) or a value that coerces to a non-integer/NaN (`indeed start abc`, `start ''`).
Common situations: Paginating with a counter that goes negative due to an off-by-one bug; empty env var interpolation producing NaN; typos like 'o' or '1st' in a script.
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
- tid must be a numeric thread id
- --from and --to must differ (got ${fromCity})
- --from and --to must differ (got ${fromCode})
- --from and --to must differ (got ${fromName})
- Unknown --since "${sinceKey}". Valid: ${Object.keys(SINCE).j
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b9293ac481dd377a.
Report an issue: GitHub.