{"record":{"id":"56c0145f08fb5d20","repo":"jackwener/OpenCLI","slug":"bbc-label-must-be-maxvalue","errorCode":null,"errorMessage":"bbc ${label} must be <= ${maxValue}","messagePattern":"bbc (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/bbc/utils.js","lineNumber":50,"sourceCode":"        out.push({\n            title: decodeHtmlEntities(extractRssTag(block, 'title')).trim(),\n            description: decodeHtmlEntities(extractRssTag(block, 'description')).trim(),\n            link: decodeHtmlEntities(extractRssTag(block, 'link')).trim(),\n            pubDate: decodeHtmlEntities(extractRssTag(block, 'pubDate')).trim(),\n            guid: decodeHtmlEntities(extractRssTag(block, 'guid')).trim(),\n        });\n    }\n    return out;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, 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(`bbc ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`bbc ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport async function bbcFetchRss(path, label) {\n    const url = `${BBC_FEED_BASE}/${path}`;\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/rss+xml, application/xml' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that feeds.bbci.co.uk is reachable from this network.',\n        );\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status} (${url})`);","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bbc/utils.js#L32-L68","documentation":"ArgumentError from `requireBoundedInt` when the value is a positive integer but exceeds `maxValue` (50 for bbc topic limit). The helper enforces an inclusive upper bound documented in the flag help ('Max headlines (1-50)').","triggerScenarios":"`bbc topic --limit 51` or higher — any limit above the maximum of 50.","commonSituations":"Users wanting more headlines than BBC's feed provides, hardcoded limits from other tooling copied over, forgetting the documented max in --help.","solutions":["Lower the limit to <= 50, e.g. `--limit 50`.","If you need more items, call the command multiple times or fetch the feed directly.","Check `--help` for the current maximum.","Clamp the value in your wrapper before invoking: `Math.min(limit, 50)`.","Read the underlying `error` message in the thrown CommandExecutionError — it includes the inner script's cause (e.g. 'Could not fetch quote for X: <reason>').","Test network reachability of barchart.com (DNS, proxy/VPN, firewall).","Verify the symbol is valid and has a quote page (try SPY).","Retry with backoff — Barchart may be rate-limiting or serving bot-detection pages."],"exampleFix":"// before\nawait cli.run(['bbc','topic','technology','--limit','100']);\n// after\nawait cli.run(['bbc','topic','technology','--limit','50']);","handlingStrategy":"validation","validationCode":"function clampLimit(v, max=50){ const n = Number(v); if (!Number.isInteger(n) || n <= 0) throw new Error('limit must be a positive integer'); return Math.min(n, max); }","typeGuard":"const isWithinBound = (v, max) => Number.isInteger(Number(v)) && Number(v) > 0 && Number(v) <= max;","tryCatchPattern":"try {\n  const items = await cli.run(['bbc','topic', topic, '--limit', String(limit)]);\n} catch (e) {\n  if (e.name === 'ArgumentError' && /must be <=/.test(e.message)) {\n    limit = 50; // clamp to max and retry\n  }\n}","preventionTips":["Clamp user-provided limits to 50 before invoking","Read the flag's --help for current bounds","Derive max from the error message ('must be <= 50') when it changes","Cap any UI slider/selector at the documented maximum"],"tags":["bbc","validation","argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}