{"record":{"id":"f8e03b9a755a2650","repo":"jackwener/OpenCLI","slug":"indeed-label-must-be-maxvalue","errorCode":null,"errorMessage":"indeed ${label} must be <= ${maxValue}","messagePattern":"indeed (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/indeed/utils.js","lineNumber":40,"sourceCode":"/**\n * Coerce a value to a strict integer. Accepts numeric strings, rejects\n * floats / non-numeric / NaN. Returns NaN on invalid input so callers can\n * decide on the right typed error.\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) {\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    }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/indeed/utils.js#L22-L58","documentation":"requireBoundedInt also enforces an upper bound: after confirming the value is a positive integer, it rejects values greater than maxValue with an ArgumentError naming the label and the cap. This prevents requests that the downstream Indeed API would reject or that the CLI deliberately caps for safety.","triggerScenarios":"Calling limit (or another bounded option) with an integer above the configured maximum, e.g. `indeed limit 1000` when maxValue is 50.","commonSituations":"Assuming the CLI accepts arbitrary page sizes; copying flags from another tool with higher limits; hardcoding a large batch size in an automation script.","solutions":["Lower the value to at most the stated maxValue from the error message.","If more results are needed, paginate with multiple calls (combine with start/offset) instead of one oversized limit.","Check the CLI docs for the current cap; it may differ between versions."],"exampleFix":"// before\nindeed limit 1000\n// after\nindeed limit 50   # then paginate for more results","handlingStrategy":"validation","validationCode":"function isValidLimit(v, max) { const n = Number(v); return Number.isInteger(n) && n > 0 && n <= max; }\nif (!isValidLimit(myLimit, 50)) myLimit = 10;","typeGuard":"function isPositiveInt(v) { return typeof v === 'number' && Number.isInteger(v) && v > 0; }","tryCatchPattern":"try { const n = requireBoundedInt(value, def, max, 'limit'); } catch (e) { if (e instanceof ArgumentError) { console.error(`Bad --limit: ${value}; using default ${def}`); } else throw e; }","preventionTips":["Validate numeric CLI inputs in a wrapper script before invoking.","Never interpolate unset env vars into flags; use ${VAR:?} guards.","Prefer omitting the flag to rely on defaults."],"tags":["cli","argument-validation","limit-exceeded"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}