{"record":{"id":"39e83f7f647343dd","repo":"jackwener/OpenCLI","slug":"dblp-label-must-be-a-positive-integer","errorCode":null,"errorMessage":"dblp ${label} must be a positive integer","messagePattern":"dblp (.+?) must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/dblp/utils.js","lineNumber":96,"sourceCode":"    return body;\n}\n\nexport async function dblpFetchXml(path, label) {\n    const res = await dblpFetch(`${DBLP_ORIGIN}${path}`, label, 'application/xml');\n    return res.text();\n}\n\nexport function coerceInt(value) {\n    if (value === undefined || value === null || value === '') return NaN;\n    const n = typeof value === 'number' ? value : Number(value);\n    return Number.isFinite(n) && Number.isInteger(n) ? n : NaN;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`dblp ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`dblp ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireQuery(value, label = 'query') {\n    const q = String(value ?? '').trim();\n    if (!q) {\n        throw new ArgumentError(`dblp ${label} cannot be empty`);\n    }\n    return q;\n}\n\nexport function requireRecordKey(value) {\n    const key = String(value ?? '').trim();\n    if (!key) {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/dblp/utils.js#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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)"],"exampleFix":"// before\nnode cli.js dblp search --limit abc\n// after\nnode cli.js dblp search --limit 20","handlingStrategy":"validation","validationCode":"function parseLimit(raw, def = 20) {\n  if (raw === undefined || raw === null || raw === '') return def;\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n <= 0) throw new Error(`--limit must be a positive integer, got \"${raw}\"`);\n  return n;\n}","typeGuard":"function isPositiveInt(v) { return typeof v === 'number' && Number.isInteger(v) && v > 0; }","tryCatchPattern":"try {\n  runDblpSearch(args);\n} catch (err) {\n  if (/must be a positive integer/.test(err.message)) {\n    console.error('Usage: dblp search --limit <positive integer, max 100>');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["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"],"tags":["validation","arguments","cli","input"],"backgroundTag":"invalid-argument-type","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}