{"record":{"id":"73a5a6d8a439e0aa","repo":"jackwener/OpenCLI","slug":"bloomberg-businessweek-limit-must-be-an-integer","errorCode":null,"errorMessage":"bloomberg businessweek --limit must be an integer between 1 and 20","messagePattern":"bloomberg businessweek --limit must be an integer between 1 and 20","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/bloomberg/businessweek.js","lineNumber":9,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CliError } from '@jackwener/opencli/errors';\n\nconst SECTION_URL = 'https://www.bloomberg.com/businessweek';\n\nexport function parseBusinessweekLimit(value) {\n    const limit = value == null || value === '' ? 1 : Number(value);\n    if (!Number.isInteger(limit) || limit < 1 || limit > 20) {\n        throw new ArgumentError('bloomberg businessweek --limit must be an integer between 1 and 20', 'Example: opencli bloomberg businessweek --limit 5');\n    }\n    return limit;\n}\n\nexport function normalizeBusinessweekStoryPath(path) {\n    const raw = typeof path === 'string' ? path.trim() : '';\n    if (!raw)\n        return '';\n    let url;\n    try {\n        url = new URL(raw, 'https://www.bloomberg.com');\n    }\n    catch {\n        return '';\n    }\n    if (url.protocol !== 'https:' || url.hostname !== 'www.bloomberg.com')\n        return '';\n    if (!/^\\/(?:news|features)\\//.test(url.pathname))","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bloomberg/businessweek.js#L1-L27","documentation":"parseBusinessweekLimit validates the --limit option for the bloomberg businessweek command: it must be an integer between 1 and 20 (defaulting to 1 when omitted/empty). This ArgumentError is thrown eagerly for out-of-range or non-integer input before any scraping happens.","triggerScenarios":"Passing --limit 0, a negative number, a value > 20, or non-numeric/non-integer input like \"abc\" or \"2.5\" to `bloomberg businessweek`.","commonSituations":"Assuming the limit is unbounded; copying a --limit from another command with a different range; passing a float or a value with units (e.g. \"5 articles\"); shell quoting turning numbers into odd strings.","solutions":["Use an integer between 1 and 20, e.g. --limit 5","Omit --limit entirely to use the default of 1","Check the command help for the documented range","Quote values correctly in the shell so numeric input reaches the parser intact"],"exampleFix":"// before\nopencli bloomberg businessweek --limit 50\n// after\nopencli bloomberg businessweek --limit 20","handlingStrategy":"validation","validationCode":"function checkLimit(v) {\n  if (v == null || v === '') return 1;\n  const n = Number(v);\n  if (!Number.isInteger(n) || n < 1 || n > 20) throw new Error('--limit must be an integer 1..20');\n  return n;\n}","typeGuard":"const isBusinessweekLimit = (v) => Number.isInteger(Number(v)) && Number(v) >= 1 && Number(v) <= 20;","tryCatchPattern":"try { await runBusinessweek({ limit }); }\ncatch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--limit')) { console.error('Usage: --limit must be 1-20, e.g. --limit 5'); }\n  else throw e;\n}","preventionTips":["Clamp user-supplied limits into 1..20 before invoking","Reject non-integer input in your own UI/wrapper first","Note the default of 1 when --limit is omitted","Document the 1-20 range in any tooling built on the command"],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}