{"record":{"id":"b0d50fc7f5e73d70","repo":"jackwener/OpenCLI","slug":"medium-limit-must-be-maxvalue","errorCode":null,"errorMessage":"medium limit must be <= ${maxValue}","messagePattern":"medium limit must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/medium/tag.js","lineNumber":72,"sourceCode":"        throw new ArgumentError('medium tag is required (e.g. \"programming\", \"javascript\")');\n    }\n    if (!TAG_PATTERN.test(s)) {\n        throw new ArgumentError(\n            `medium tag \"${value}\" is not valid`,\n            'Tags are lowercase alphanumeric, optionally hyphenated (e.g. \"machine-learning\").',\n        );\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('medium limit must be a positive integer');\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`medium limit must be <= ${maxValue}`);\n    }\n    return n;\n}\n\ncli({\n    site: 'medium',\n    name: 'tag',\n    access: 'read',\n    description: 'Latest Medium articles tagged with a given keyword (RSS feed)',\n    domain: 'medium.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'tag', positional: true, required: true, help: 'Lowercase tag slug (e.g. \"programming\", \"machine-learning\")' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max articles (1-25 — single RSS page)' },\n    ],\n    columns: ['rank', 'title', 'author', 'description', 'categories', 'published', 'url'],\n    func: async (args) => {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/medium/tag.js#L54-L90","documentation":"requireBoundedInt enforces an upper bound on the medium tag --limit option after validating positivity. When the supplied integer exceeds the maxValue configured for the command, ArgumentError is thrown with the exact limit so the user knows the ceiling.","triggerScenarios":"Running `medium tag <tag> --limit <n>` where n is a positive integer but greater than the command's configured maxValue (e.g. asking for hundreds of posts when the adapter caps the limit).","commonSituations":"Users expecting unlimited pagination via a huge limit; copying limits from other CLIs with higher caps; scripts computing counts (e.g. full feed size) and passing them straight through.","solutions":["Lower the --limit value to at most the maxValue shown in the error message.","Fetch in multiple bounded calls if you need more items than one request allows.","Inspect cli() at the bottom of clis/medium/tag.js to see the supported max for the limit flag.","If the cap is genuinely too low for your use case, request a higher default in an upstream issue."],"exampleFix":"// before\nmedium tag programming --limit 1000\n// after (assuming max 50)\nmedium tag programming --limit 50","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 50; // check cli() in clis/medium/tag.js for the real cap\nconst n = Number(limit);\nif (!Number.isInteger(n) || n <= 0 || n > MAX_LIMIT) {\n  throw new Error(`--limit must be a positive integer <= ${MAX_LIMIT}`);\n}","typeGuard":"function isBoundedInt(v, max) {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;\n}","tryCatchPattern":"try {\n  await run(['medium', 'tag', tag, '--limit', String(limit)]);\n} catch (e) {\n  const m = /limit must be <= (\\d+)/.exec(e.message);\n  if (m) {\n    console.error(`Clamping limit ${limit} to ${m[1]}`);\n    await run(['medium', 'tag', tag, '--limit', m[1]]);\n  } else throw e;\n}","preventionTips":["Read the maxValue from the error or the cli() definition before scripting large fetches.","Clamp computed limits with Math.min(limit, maxValue) before invoking.","Never assume unlimited pagination — paginate with multiple calls.","Validate all user-supplied options against the command's documented bounds."],"tags":["cli","validation","argument-error","limits"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}