{"record":{"id":"54cf22209ca63201","repo":"jackwener/OpenCLI","slug":"limit-must-be-a-positive-integer-max","errorCode":null,"errorMessage":"limit must be a positive integer ≤ ${max}","messagePattern":"limit must be a positive integer ≤ (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/manus/_utils.js","lineNumber":32,"sourceCode":"    try {\n        const url = new URL(String(value || ''));\n        const host = url.hostname.toLowerCase();\n        return url.protocol === 'https:' && (host === MANUS_DOMAIN || host === `www.${MANUS_DOMAIN}`);\n    } catch {\n        return false;\n    }\n}\n\n/**\n * Validate a `--limit N` argument: must be a positive integer ≤ `max`.\n * Negatives, zero, NaN, Infinity, and non-integers all reject. Manus's\n * Connect-RPC backend enforces these server-side via Buf Validate; failing\n * client-side gives the user a clearer error and skips a wasted round-trip.\n */\nexport function validatedLimit(raw, fallback, max = 1000) {\n    const n = raw == null ? fallback : Number(raw);\n    if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1 || n > max) {\n        throw new ArgumentError('limit', `must be a positive integer ≤ ${max}`);\n    }\n    return n;\n}\n\nexport function unwrapEvaluateResult(payload) {\n    if (\n        payload\n        && typeof payload === 'object'\n        && !Array.isArray(payload)\n        && Object.prototype.hasOwnProperty.call(payload, 'session')\n        && Object.prototype.hasOwnProperty.call(payload, 'data')\n    ) {\n        return payload.data;\n    }\n    return payload;\n}\n\nfunction extractErrorMessage(payload) {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/manus/_utils.js#L14-L50","documentation":"ArgumentError thrown by validatedLimit() when the provided limit is not a finite integer between 1 and max (default 1000). The CLI mirrors the Connect-RPC/Buf Validate server rules client-side so users get a clear error without a wasted round-trip.","triggerScenarios":"Calling a list-style manus command (sessions, connectors, skills) with --limit 0, a negative number, a float, a non-numeric string, or a value above max; omitting raw while fallback itself is invalid is not possible since fallback defaults are valid.","commonSituations":"Passing --limit 0 expecting 'unlimited', copy-pasting limits like 5000 from other CLIs, quoting '10 ' or 'ten', scripts computing limit via division producing floats.","solutions":["Pass an integer between 1 and 1000, e.g. --limit 100.","Omit --limit to use the built-in fallback default.","In scripts, Math.floor/parseInt the value and clamp: Math.min(Math.max(1, n), 1000).","If you need more than max results, paginate instead of raising limit."],"exampleFix":"// before\nmanus sessions --limit 0\n// after\nmanus sessions --limit 100","handlingStrategy":"validation","validationCode":"function clampLimit(raw, max = 1000) {\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n < 1 || n > max) throw new RangeError(`limit must be an integer 1..${max}`);\n  return n;\n}","typeGuard":"function isValidLimit(v, max = 1000) { return Number.isInteger(v) && v >= 1 && v <= max; }","tryCatchPattern":"try {\n  const sessions = await manusSessions({ limit });\n} catch (e) {\n  if (/limit must be a positive integer/.test(e.message)) {\n    console.error(`--limit must be an integer 1..1000, got: ${limit}`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always validate/clamp user-supplied limits before calling CLI or API.","Never use 0 to mean 'unlimited' — omit the flag for defaults.","Use parseInt/Math.floor when deriving limits from computed values."],"tags":["validation","argument","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}