{"record":{"id":"b3db15995e3935f1","repo":"jackwener/OpenCLI","slug":"openreview-label-must-be-maxvalue","errorCode":null,"errorMessage":"openreview ${label} must be <= ${maxValue}","messagePattern":"openreview (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/openreview/utils.js","lineNumber":33,"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 = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`openreview ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`openreview ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireNonNegativeInt(value, defaultValue, label = 'offset') {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n < 0) {\n        throw new ArgumentError(`openreview ${label} must be a non-negative integer`);\n    }\n    return n;\n}\n\nexport function requireForumId(value, label = 'id') {\n    const id = String(value ?? '').trim();\n    if (!id) {\n        throw new ArgumentError(`openreview ${label} is required`);\n    }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/openreview/utils.js#L15-L51","documentation":"After confirming the value is a positive integer, requireBoundedInt enforces the per-command maximum (e.g. author limit max 1000, search limit max 50). Exceeding it throws ArgumentError with the label and max value, preventing requests the OpenReview API would reject or that the CLI does not support.","triggerScenarios":"A limit argument is a valid positive integer but greater than the command's maxValue — e.g. --limit 100 on search (max 50) or --limit 5000 on author (max 1000).","commonSituations":"Copy-pasting a limit valid for one command into another with a lower cap; assuming the API allows arbitrary page sizes; scripts using a global page-size constant larger than the endpoint's max.","solutions":["Lower the limit to the command's documented maximum (search: 50, author: 1000)","Read the error message which states the exact max: 'must be <= <maxValue>'","Parameterize scripts with a per-command max instead of one global page size","Omit the flag to use the command default"],"exampleFix":"// before\nopenreview search \"transformer\" --limit 100\n// after\nopenreview search \"transformer\" --limit 50","handlingStrategy":"validation","validationCode":"const n = coerceInt(rawLimit);\nconst MAX = 50; // per-command max (author: 1000, search: 50)\nif (!Number.isInteger(n) || n <= 0 || n > MAX) {\n    throw new Error(`limit must be an integer between 1 and ${MAX}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Know each command's cap (search: 50, author: 1000) before setting limits","Don't reuse one global page-size constant across commands","Read the error message — it states the exact max","Clamp instead of fail when generating limits programmatically: Math.min(desired, MAX)"],"tags":["argument-validation","pagination","cli","input-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}