{"record":{"id":"dc4e1d9994cebcda","repo":"jackwener/OpenCLI","slug":"osv-label-must-be-maxvalue","errorCode":null,"errorMessage":"osv ${label} must be <= ${maxValue}","messagePattern":"osv (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/osv/utils.js","lineNumber":81,"sourceCode":"        );\n    }\n    if (!OSV_ECOSYSTEMS.has(s)) {\n        throw new ArgumentError(\n            `osv --ecosystem \"${value}\" is not a recognised OSV ecosystem`,\n            `Pick one of: ${[...OSV_ECOSYSTEMS].join(', ')}.`,\n        );\n    }\n    return s;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`osv ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`osv ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nasync function readJson(resp, label) {\n    let body;\n    try {\n        body = await resp.json();\n    }\n    catch (err) {\n        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);\n    }\n    return body;\n}\n\nexport async function osvGet(url, label) {\n    let resp;\n    try {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/osv/utils.js#L63-L99","documentation":"requireBoundedInt enforces an upper bound (maxValue) on numeric options like --limit; values above the cap are rejected so a single request cannot hammer the OSV API. The error message includes the exact maximum.","triggerScenarios":"Passing --limit with a value greater than the command's maximum (e.g. --limit 10000 when max is 100 or 1000), often from config or a 'fetch everything' mindset.","commonSituations":"Setting a very large limit in CI config; confusing page size with total count; copying a limit from another tool with different bounds.","solutions":["Read the error message for the exact cap and lower your value (e.g. --limit 100).","Paginate: issue multiple queries instead of one oversized limit.","Clamp the value in your wrapper: Math.min(userLimit, MAX).","Check the command docs for the supported maxValue."],"exampleFix":"// before\nosvQuery({ limit: 5000 });\n// after\nosvQuery({ limit: Math.min(5000, 1000) });","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 1000;\nconst n = Number(raw);\nif (Number.isInteger(n) && n > MAX_LIMIT) {\n  throw new Error(`--limit must be <= ${MAX_LIMIT}`);\n}","typeGuard":"const isWithinLimit = (v, max) =>\n  Number.isInteger(Number(v)) && Number(v) > 0 && Number(v) <= max;","tryCatchPattern":"try {\n  const result = await osvQuery({ limit });\n} catch (e) {\n  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {\n    console.error(`Lower --limit (max shown in message) or paginate instead`);\n    return;\n  }\n  throw e;\n}","preventionTips":["Clamp user/config limits with Math.min(value, MAX) before invoking.","Paginate large result sets instead of one oversized query.","Check the command's documented maximum before setting config values.","Keep limit values modest in CI to avoid API strain."],"tags":["argument-validation","numeric-validation","bounds","osv"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}