jackwener/OpenCLI · warning · ArgumentError

bbc ${label} must be <= ${maxValue}

Error message

bbc ${label} must be <= ${maxValue}

What it means

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)').

Source

Thrown at clis/bbc/utils.js:50

        out.push({
            title: decodeHtmlEntities(extractRssTag(block, 'title')).trim(),
            description: decodeHtmlEntities(extractRssTag(block, 'description')).trim(),
            link: decodeHtmlEntities(extractRssTag(block, 'link')).trim(),
            pubDate: decodeHtmlEntities(extractRssTag(block, 'pubDate')).trim(),
            guid: decodeHtmlEntities(extractRssTag(block, 'guid')).trim(),
        });
    }
    return out;
}

export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
    const raw = value ?? defaultValue;
    const n = typeof raw === 'number' ? raw : Number(raw);
    if (!Number.isInteger(n) || n <= 0) {
        throw new ArgumentError(`bbc ${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`bbc ${label} must be <= ${maxValue}`);
    }
    return n;
}

export async function bbcFetchRss(path, label) {
    const url = `${BBC_FEED_BASE}/${path}`;
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/rss+xml, application/xml' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that feeds.bbci.co.uk is reachable from this network.',
        );
    }
    if (!resp.ok) {
        throw new CommandExecutionError(`${label} returned HTTP ${resp.status} (${url})`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the limit to <= 50, e.g. `--limit 50`.
  2. If you need more items, call the command multiple times or fetch the feed directly.
  3. Check `--help` for the current maximum.
  4. Clamp the value in your wrapper before invoking: `Math.min(limit, 50)`.
  5. 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>').
  6. Test network reachability of barchart.com (DNS, proxy/VPN, firewall).
  7. Verify the symbol is valid and has a quote page (try SPY).
  8. Retry with backoff — Barchart may be rate-limiting or serving bot-detection pages.

Example fix

// before
await cli.run(['bbc','topic','technology','--limit','100']);
// after
await cli.run(['bbc','topic','technology','--limit','50']);
Defensive patterns

Strategy: validation

Validate before calling

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); }

Type guard

const isWithinBound = (v, max) => Number.isInteger(Number(v)) && Number(v) > 0 && Number(v) <= max;

Try / catch

try {
  const items = await cli.run(['bbc','topic', topic, '--limit', String(limit)]);
} catch (e) {
  if (e.name === 'ArgumentError' && /must be <=/.test(e.message)) {
    limit = 50; // clamp to max and retry
  }
}

Prevention

When it happens

Trigger: `bbc topic --limit 51` or higher — any limit above the maximum of 50.

Common situations: Users wanting more headlines than BBC's feed provides, hardcoded limits from other tooling copied over, forgetting the documented max in --help.

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/56c0145f08fb5d20. Report an issue: GitHub.