jackwener/OpenCLI · error · CliError

ARGUMENT

ARGUMENT

Error message

Unknown Bloomberg feed: ${name}

What it means

Thrown by fetchBloombergFeed when the feed name is not a key in BLOOMBERG_FEEDS. This is an immediate argument validation error (ARGUMENT) raised before any network request. It prevents wasted fetches against an unsupported feed identifier.

Source

Thrown at clis/bloomberg/utils.js:24

    industries: 'https://feeds.bloomberg.com/industries/news.rss',
    tech: 'https://feeds.bloomberg.com/technology/news.rss',
    politics: 'https://feeds.bloomberg.com/politics/news.rss',
    opinions: 'https://feeds.bloomberg.com/bview/news.rss',
    green: 'https://feeds.bloomberg.com/green/news.rss',
    crypto: 'https://feeds.bloomberg.com/crypto/news.rss',
    pursuits: 'https://feeds.bloomberg.com/pursuits/news.rss',
};
// Note: the Businessweek RSS feed (feeds.bloomberg.com/businessweek/news.rss) is now served
// empty by Bloomberg, so the `businessweek` command reads the section page instead (see
// businessweek.js). Other sections still publish working RSS feeds.
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (compatible; opencli)';
// Bloomberg's edge occasionally serves a transient empty/non-OK RSS response under load; a
// couple of quick retries turn those intermittent misses into a successful fetch instead of a
// hard NOT_FOUND. A feed that is genuinely empty still surfaces NOT_FOUND after the retries.
export async function fetchBloombergFeed(name, limit = 1) {
    const feedUrl = BLOOMBERG_FEEDS[name];
    if (!feedUrl) {
        throw new CliError('ARGUMENT', `Unknown Bloomberg feed: ${name}`);
    }
    let lastError;
    for (let attempt = 0; attempt < 3; attempt += 1) {
        if (attempt > 0) {
            await new Promise((resolve) => setTimeout(resolve, 400 * attempt));
        }
        const resp = await fetch(feedUrl, {
            headers: { 'User-Agent': DEFAULT_USER_AGENT },
        });
        if (!resp.ok) {
            lastError = new CliError('FETCH_ERROR', `Bloomberg RSS HTTP ${resp.status}`, 'Bloomberg may be temporarily unavailable; try again later.');
            continue;
        }
        const xml = await resp.text();
        const items = parseBloombergRss(xml);
        if (items.length) {
            const count = Math.max(1, Math.min(Number(limit) || 1, 20));
            return items.slice(0, count);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the feed name against the BLOOMBERG_FEEDS keys for exact spelling/casing
  2. Update the library version in case feed names changed
  3. Whitelist user-supplied feed names before calling fetchBloombergFeed

Example fix

// before
await fetchBloombergFeed('markets-tech');
// after
await fetchBloombergFeed('technology'); // exact key from BLOOMBERG_FEEDS
Defensive patterns

Strategy: validation

Validate before calling

import { BLOOMBERG_FEEDS } from './clis/bloomberg/utils.js';
function isValidFeed(name) {
  return typeof name === 'string' && Object.prototype.hasOwnProperty.call(BLOOMBERG_FEEDS, name);
}
if (!isValidFeed(name)) throw new Error(`Unknown feed: ${name}`);

Type guard

null

Try / catch

try {
  await fetchBloombergFeed(name);
} catch (e) {
  if (e.code === 'ARGUMENT' && /Unknown Bloomberg feed/.test(e.message)) {
    // correct the feed name or list available feeds
  }
}

Prevention

When it happens

Trigger: Calling fetchBloombergFeed(name) with a typo, wrong casing, or a feed name not defined in BLOOMBERG_FEEDS.

Common situations: Hand-editing feed names in config; renaming feeds in an upgraded library version; passing user input without whitelisting against the known feed keys.

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