jackwener/OpenCLI · error · ArgumentError

bloomberg businessweek --limit must be an integer between 1

Error message

bloomberg businessweek --limit must be an integer between 1 and 20

What it means

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.

Source

Thrown at clis/bloomberg/businessweek.js:9

import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CliError } from '@jackwener/opencli/errors';

const SECTION_URL = 'https://www.bloomberg.com/businessweek';

export function parseBusinessweekLimit(value) {
    const limit = value == null || value === '' ? 1 : Number(value);
    if (!Number.isInteger(limit) || limit < 1 || limit > 20) {
        throw new ArgumentError('bloomberg businessweek --limit must be an integer between 1 and 20', 'Example: opencli bloomberg businessweek --limit 5');
    }
    return limit;
}

export function normalizeBusinessweekStoryPath(path) {
    const raw = typeof path === 'string' ? path.trim() : '';
    if (!raw)
        return '';
    let url;
    try {
        url = new URL(raw, 'https://www.bloomberg.com');
    }
    catch {
        return '';
    }
    if (url.protocol !== 'https:' || url.hostname !== 'www.bloomberg.com')
        return '';
    if (!/^\/(?:news|features)\//.test(url.pathname))

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use an integer between 1 and 20, e.g. --limit 5
  2. Omit --limit entirely to use the default of 1
  3. Check the command help for the documented range
  4. Quote values correctly in the shell so numeric input reaches the parser intact

Example fix

// before
opencli bloomberg businessweek --limit 50
// after
opencli bloomberg businessweek --limit 20
Defensive patterns

Strategy: validation

Validate before calling

function checkLimit(v) {
  if (v == null || v === '') return 1;
  const n = Number(v);
  if (!Number.isInteger(n) || n < 1 || n > 20) throw new Error('--limit must be an integer 1..20');
  return n;
}

Type guard

const isBusinessweekLimit = (v) => Number.isInteger(Number(v)) && Number(v) >= 1 && Number(v) <= 20;

Try / catch

try { await runBusinessweek({ limit }); }
catch (e) {
  if (e instanceof ArgumentError && e.message.includes('--limit')) { console.error('Usage: --limit must be 1-20, e.g. --limit 5'); }
  else throw e;
}

Prevention

When it happens

Trigger: Passing --limit 0, a negative number, a value > 20, or non-numeric/non-integer input like "abc" or "2.5" to `bloomberg businessweek`.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/73a5a6d8a439e0aa. Report an issue: GitHub.