{"record":{"id":"160f69b2413c67a5","repo":"jackwener/OpenCLI","slug":"lobsters-limit-must-be-maxvalue","errorCode":null,"errorMessage":"lobsters limit must be <= ${maxValue}","messagePattern":"lobsters limit must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/lobsters/domain.js","lineNumber":30,"sourceCode":"function requireDomain(value) {\n    const s = String(value ?? '').trim().toLowerCase();\n    if (!s) {\n        throw new ArgumentError('lobsters domain is required (e.g. \"github.com\" or \"arxiv.org\")');\n    }\n    if (!DOMAIN_PATTERN.test(s)) {\n        throw new ArgumentError(`lobsters domain \"${value}\" is not a valid hostname`);\n    }\n    return s;\n}\n\nfunction requireBoundedInt(value, defaultValue, maxValue) {\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('lobsters limit must be a positive integer');\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`lobsters limit must be <= ${maxValue}`);\n    }\n    return n;\n}\n\ncli({\n    site: 'lobsters',\n    name: 'domain',\n    access: 'read',\n    description: 'Lobste.rs stories submitted from a specific domain',\n    domain: 'lobste.rs',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'domain', positional: true, required: true, help: 'Source domain (e.g. github.com, arxiv.org, blog.cloudflare.com)' },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of stories (1-25 — single page)' },\n    ],\n    columns: ['rank', 'id', 'title', 'score', 'author', 'comments', 'created_at', 'tags', 'submission_url', 'comments_url'],\n    func: async (args) => {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lobsters/domain.js#L12-L48","documentation":"Thrown by requireBoundedInt() when the parsed limit is a positive integer but exceeds maxValue, the API's configured upper bound. The library enforces this locally so clients never send a request that Lobste.rs would reject or that would be wasteful.","triggerScenarios":"Calling limit(n, defaultValue, maxValue) with n > maxValue, e.g. limit(500, 25, 100).","commonSituations":"Users pass `--limit 1000` expecting more results than the adapter allows; a config file holds an oversized value; the maxValue was tightened in a newer library version and previously valid configs now exceed it.","solutions":["Lower the limit to the allowed max (the error message states the exact bound, e.g. `<= 100`)","Clamp before calling: Math.min(requested, maxValue)","Update hardcoded configs/scripts that still use old, larger limits","Consult the CLI docs for the current maximum allowed limit"],"exampleFix":"// before\nawait cli.limit(1000); // max is 100\n// after\nawait cli.limit(Math.min(1000, 100));","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 100; // check library docs for the exact bound\nconst n = Number.parseInt(rawLimit, 10);\nawait cli.limit(Number.isInteger(n) && n > 0 ? Math.min(n, MAX_LIMIT) : undefined);","typeGuard":"function isInBoundedRange(v, maxValue) {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= maxValue;\n}","tryCatchPattern":"try {\n  await cli.limit(n);\n} catch (err) {\n  if (err instanceof ArgumentError && /limit must be <=/.test(err.message)) {\n    const max = Number(err.message.match(/<= (\\d+)/)?.[1] ?? 100);\n    return cli.limit(Math.min(n, max));\n  }\n  throw err;\n}","preventionTips":["Clamp user-supplied limits with Math.min(n, maxValue) at the boundary","Centralize the max constant in one place shared by your config validation","Re-check configs after upgrading the library in case the bound changed"],"tags":["argument-error","validation","bounds-check","cli"],"backgroundTag":"value-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}