{"record":{"id":"07a4ac2fbfd705c4","repo":"jackwener/OpenCLI","slug":"label-must-be-maxvalue-07a4ac","errorCode":null,"errorMessage":"${label} must be <= ${maxValue}","messagePattern":"(.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/_atlassian/shared.js","lineNumber":281,"sourceCode":"    }\n    const s = String(value).trim();\n    if (!s) throw new CommandExecutionError(`${label} did not include a stable ${field}.`);\n    return s;\n}\n\nexport function requireNonEmptyRows(rows, label, hint) {\n    if (!rows.length) throw new EmptyResultError(label, hint);\n    return rows;\n}\n\nexport function parseLimit(value, defaultValue = 20, maxValue = 100, 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(`${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireExecute(args, commandName) {\n    if (args.execute !== true) {\n        throw new ArgumentError(`${commandName} requires --execute to perform a remote write`);\n    }\n}\n\nexport async function readUtf8File(filePath) {\n    const path = requireString(filePath, '--file');\n    let fileStat;\n    try {\n        fileStat = await stat(path);\n    } catch {\n        throw new ArgumentError(`File not found: ${path}`);\n    }","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/_atlassian/shared.js#L263-L299","documentation":"parseLimit throws this ArgumentError when the requested limit exceeds the maximum allowed (default 100). Atlassian's REST APIs cap page sizes; requesting more would either fail upstream or be truncated, so the CLI enforces the bound locally.","triggerScenarios":"Passing --limit 500 or --limit 1000 to a list/search command whose maxValue is 100; scripts that set large page sizes to 'fetch everything'.","commonSituations":"Trying to export all pages in one call; copying a limit from another tool with a higher cap; hardcoded defaults from older scripts before the cap existed.","solutions":["Lower the limit to <= 100 (the default maximum).","Paginate: loop requests with limit=100 and a cursor/next token until all rows are fetched.","If you need the full dataset, use the CLI's export/bulk command if available, or aggregate paginated calls.","Clamp the value in scripts: const n = Math.min(requested, 100)."],"exampleFix":"// before\nopencli confluence list --space DEV --limit 500\n// after — paginate\nlet start = 0;\nwhile (true) {\n  const rows = await run(['confluence', 'list', '--space', 'DEV', '--limit', '100', '--offset', String(start)]);\n  all.push(...rows); if (rows.length < 100) break; start += 100;\n}","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 100;\nfunction clampLimit(v, def = 20) {\n  const n = parseLimitSafe(v, def);\n  if (n > MAX_LIMIT) return MAX_LIMIT;\n  return n;\n}","typeGuard":"function isWithinLimit(n, max = 100) { return Number.isInteger(n) && n > 0 && n <= max; }","tryCatchPattern":"try {\n  await listCmd({ limit: requested });\n} catch (e) {\n  if (/must be <=/.test(e.message)) {\n    console.error(`Requested limit ${requested} exceeds the API cap — clamping to 100 and paginating.`);\n    await paginate(requested);\n  } else throw e;\n}","preventionTips":["Clamp limit to 100 in wrapper code instead of passing user input raw.","Implement pagination loops rather than ever-increasing page sizes.","Centralize the max-value constant for all list commands.","Document the API page-size cap in team scripts/READMEs."],"tags":["validation","pagination","arguments","cli","limits"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}