{"record":{"id":"b9293ac481dd377a","repo":"jackwener/OpenCLI","slug":"indeed-label-must-be-a-non-negative-integer","errorCode":null,"errorMessage":"indeed ${label} must be a non-negative integer","messagePattern":"indeed (.+?) must be a non-negative integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/indeed/utils.js","lineNumber":49,"sourceCode":"}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label) {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`indeed ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`indeed ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireNonNegativeInt(value, defaultValue, label) {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n < 0) {\n        throw new ArgumentError(`indeed ${label} must be a non-negative integer`);\n    }\n    return n;\n}\n\nexport function requireJobKey(value) {\n    const id = String(value ?? '').trim().toLowerCase();\n    if (!id) {\n        throw new ArgumentError('indeed job id is required');\n    }\n    if (!JK_PATTERN.test(id)) {\n        throw new ArgumentError(`indeed job id \"${value}\" is not a valid jk (expected 16-char lowercase hex)`);\n    }\n    return id;\n}\n\nexport function requireQuery(value, label = 'query') {\n    const q = String(value ?? '').trim();\n    if (!q) {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/indeed/utils.js#L31-L67","documentation":"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.","triggerScenarios":"Calling start with a negative number (`indeed start -10`) or a value that coerces to a non-integer/NaN (`indeed start abc`, `start ''`).","commonSituations":"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.","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."],"exampleFix":"// before\nindeed start -10\n// after\nindeed start 0","handlingStrategy":"validation","validationCode":"const n = Number(raw); if (!(Number.isInteger(n) && n > 0 && n <= maxValue)) raw = maxValue;","typeGuard":"function isWithinBound(v, max) { return Number.isInteger(v) && v > 0 && v <= max; }","tryCatchPattern":"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; }","preventionTips":["Cap batch sizes to documented maxima in automation scripts.","Paginate instead of raising the limit.","Consult the CLI help for current caps."],"tags":["cli","argument-validation","input-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}