{"record":{"id":"dc3dfd20508ab73c","repo":"jackwener/OpenCLI","slug":"openreview-label-must-be-a-positive-integer","errorCode":null,"errorMessage":"openreview ${label} must be a positive integer","messagePattern":"openreview (.+?) must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/openreview/utils.js","lineNumber":30,"sourceCode":"/** Forum / note IDs on OpenReview are short URL-safe slugs (typically 10 chars). */\nconst ID_PATTERN = /^[A-Za-z0-9_-]{6,20}$/;\n\n/**\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();","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/openreview/utils.js#L12-L48","documentation":"requireBoundedInt is the shared integer validator for OpenReview CLI limit/offset style options. It coerces the value with coerceInt and rejects anything that is not a positive integer (0 and negatives included) before checking the upper bound. This ensures API pagination parameters are always valid positive integers.","triggerScenarios":"A limit argument (defaulting when undefined, so only when explicitly passed) coerces to a non-integer, 0, or negative number — e.g. --limit abc, --limit 0, --limit -5, --limit 2.5.","commonSituations":"Typo or accidental characters in the CLI flag value; scripts interpolating empty/unset variables producing strings coerceInt rejects; passing 0 expecting 'unlimited'; locale-formatted numbers like '1,000'.","solutions":["Pass a positive integer, e.g. --limit 25","Omit the flag to use the command's default","Verify the value is not 0, negative, or fractional","Check upstream variables feeding the flag are set and numeric"],"exampleFix":"// before\nopenreview author ~Jane_Doe --limit 0\n// after\nopenreview author ~Jane_Doe --limit 50","handlingStrategy":"validation","validationCode":"const n = coerceInt(rawLimit);\nif (!Number.isInteger(n) || n <= 0) {\n    throw new Error(`limit must be a positive integer, got: ${rawLimit}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit --limit to use safe defaults","Validate numeric flags in wrapper scripts before invoking","Reject 0/negatives early — the CLI requires positive integers","Avoid locale-formatted numbers like '1,000'"],"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"}