{"record":{"id":"85d838ae5d55987d","repo":"jackwener/OpenCLI","slug":"label-must-be-an-integer-min-85d838","errorCode":null,"errorMessage":"${label} must be an integer >= ${min}","messagePattern":"(.+?) must be an integer >= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/lobsters/read.js","lineNumber":40,"sourceCode":"    if (res.status === 404) {\n        throw new EmptyResultError(`lobsters/${shortId}`, 'Story not found');\n    }\n    if (!res.ok) {\n        throw new CommandExecutionError(`Lobsters API HTTP ${res.status} for story ${shortId}`, 'Check the short id');\n    }\n    return res.json();\n}\n\nfunction requirePositiveInt(value, label) {\n    if (!Number.isInteger(value) || value <= 0) {\n        throw new ArgumentError(`${label} must be a positive integer`);\n    }\n    return value;\n}\n\nfunction requireMinInt(value, min, label) {\n    if (!Number.isInteger(value) || value < min) {\n        throw new ArgumentError(`${label} must be an integer >= ${min}`);\n    }\n    return value;\n}\n\n/** Lobsters returns comment text as a small HTML subset — convert to plain text. */\nfunction htmlToText(html) {\n    if (!html) return '';\n    return String(html)\n        .replace(/<p>/gi, '\\n\\n')\n        .replace(/<\\/p>/gi, '')\n        .replace(/<br\\s*\\/?>/gi, '\\n')\n        .replace(/<i>(.*?)<\\/i>/gi, '$1')\n        .replace(/<em>(.*?)<\\/em>/gi, '$1')\n        .replace(/<strong>(.*?)<\\/strong>/gi, '$1')\n        .replace(/<a[^>]*href=\"([^\"]*)\"[^>]*>(.*?)<\\/a>/gi, '$2 ($1)')\n        .replace(/<pre><code>([\\s\\S]*?)<\\/code><\\/pre>/gi, '\\n$1\\n')\n        .replace(/<code>(.*?)<\\/code>/gi, '`$1`')\n        .replace(/<[^>]+>/g, '')","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lobsters/read.js#L22-L58","documentation":"Thrown by requireMinInt in clis/lobsters/read.js:40 when --max-length is not an integer or is below the minimum of 100. This flag caps the characters per comment/story body; the library enforces a floor so truncation logic and output formatting behave predictably.","triggerScenarios":"Passing `--max-length 50`, `--max-length 0`, `--max-length -1`, or a non-integer like `--max-length 99.9` raises ArgumentError with 'must be an integer >= 100'.","commonSituations":"Trying to get ultra-compact output by setting a tiny max-length; scripting the flag from a config with an unset/zero value; typos like 10o0 that fail int parsing.","solutions":["Pass an integer of at least 100, e.g. `lobsters read 6cmh6h --max-length 500`","Omit the flag to use the default of 2000","Clamp values in calling code: Math.max(100, Math.floor(n)) before passing","For short output, post-truncate results yourself instead of setting max-length below 100"],"exampleFix":"// before\nlobsters read 6cmh6h --max-length 50\n// after\nlobsters read 6cmh6h --max-length 100","handlingStrategy":"validation","validationCode":"function assertMaxLength(v) {\n  if (!Number.isInteger(v) || v < 100) throw new Error('--max-length must be an integer >= 100');\n}\nassertMaxLength(maxLength);","typeGuard":"function isValidMaxLength(v) {\n  return Number.isInteger(v) && v >= 100;\n}","tryCatchPattern":"try {\n  await run(['lobsters', 'read', id, '--max-length', String(maxLength)]);\n} catch (e) {\n  if (e.message.includes('must be an integer >= ')) {\n    maxLength = Math.max(100, Math.floor(Number(maxLength)));\n    return run(['lobsters', 'read', id, '--max-length', String(maxLength)]);\n  }\n  throw e;\n}","preventionTips":["Clamp user-supplied values: Math.max(100, Math.floor(v))","Omit the flag to use the default 2000","Never try values below 100 — truncate downstream instead","Validate types in scripts before shelling out"],"tags":["validation","cli-arguments","input-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}