jackwener/OpenCLI · error · ArgumentError
dblp ${label} must be a positive integer
Error message
dblp ${label} must be a positive integer What it means
Thrown by requireBoundedInt when the provided value (or its default) does not coerce to a positive integer via coerceInt. It is an ArgumentError — a caller-input validation failure, not a network problem.
Source
Thrown at clis/dblp/utils.js:96
return body;
}
export async function dblpFetchXml(path, label) {
const res = await dblpFetch(`${DBLP_ORIGIN}${path}`, label, 'application/xml');
return res.text();
}
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(`dblp ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`dblp ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireQuery(value, label = 'query') {
const q = String(value ?? '').trim();
if (!q) {
throw new ArgumentError(`dblp ${label} cannot be empty`);
}
return q;
}
export function requireRecordKey(value) {
const key = String(value ?? '').trim();
if (!key) {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a positive whole number, e.g. --limit 20
- Check the shell variable feeding the flag is set and numeric
- Remember the default (e.g. 20) applies when the flag is omitted — omit it if unsure
- Check the upper bound too (must be <= maxValue, e.g. 100)
Example fix
// before node cli.js dblp search --limit abc // after node cli.js dblp search --limit 20
Defensive patterns
Strategy: validation
Validate before calling
function parseLimit(raw, def = 20) {
if (raw === undefined || raw === null || raw === '') return def;
const n = Number(raw);
if (!Number.isInteger(n) || n <= 0) throw new Error(`--limit must be a positive integer, got "${raw}"`);
return n;
} Type guard
function isPositiveInt(v) { return typeof v === 'number' && Number.isInteger(v) && v > 0; } Try / catch
try {
runDblpSearch(args);
} catch (err) {
if (/must be a positive integer/.test(err.message)) {
console.error('Usage: dblp search --limit <positive integer, max 100>');
process.exitCode = 2;
} else throw err;
} Prevention
- Validate/sanitize flags with Number() before passing them on
- Quote shell variables so empty values are caught early
- Omit --limit to use the safe default (20)
- Reject floats and strings with units at the script boundary
When it happens
Trigger: Calling a dblp command with a --limit (or similar) that is 0, negative, non-numeric, a float, or an empty string, e.g. --limit abc, --limit 0, --limit 2.5.
Common situations: Typos in CLI flags (--limt passing wrong value); scripting with unquoted/unset shell variables that resolve to empty strings; passing strings with whitespace or units like '50 items'.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- dblp ${label} cannot be empty
- dblp paper key is required
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/39e83f7f647343dd.
Report an issue: GitHub.