jackwener/OpenCLI · warning · EmptyResultError
BBC ${raw} feed returned no items.
Error message
BBC ${raw} feed returned no items. What it means
EmptyResultError from `bbc topic` when the RSS feed was fetched successfully but `parseRssItems(xml)` produced zero items. The library treats a parsed-but-empty feed as a result-level failure so users know the topic is valid yet returned no headlines.
Source
Thrown at clis/bbc/topic.js:47
browser: false,
args: [
{ name: 'topic', positional: true, required: true, help: `Section name (${TOPICS.join(' / ')})` },
{ name: 'limit', type: 'int', default: 20, help: 'Max headlines (1-50)' },
],
columns: ['rank', 'title', 'description', 'pubDate', 'url'],
func: async (args) => {
const raw = String(args.topic ?? '').trim().toLowerCase().replace(/[\s-]+/g, '_');
if (!TOPICS.includes(raw)) {
throw new ArgumentError(
`bbc topic "${args.topic}" is not supported`,
`Supported topics: ${TOPICS.join(', ')}`,
);
}
const limit = requireBoundedInt(args.limit, 20, 50);
const xml = await bbcFetchRss(`${raw}/rss.xml`, `bbc topic ${raw}`);
const items = parseRssItems(xml);
if (!items.length) {
throw new EmptyResultError('bbc topic', `BBC ${raw} feed returned no items.`);
}
return items.slice(0, limit).map((it, i) => ({
rank: i + 1,
title: it.title,
description: it.description,
pubDate: pubDateToIso(it.pubDate),
url: it.link,
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry later — the feed may be temporarily empty or mid-publish.
- Check the raw XML at https://feeds.bbci.co.uk/<topic>/rss.xml to confirm items exist.
- If the feed uses Atom <entry> tags, update/fix the RSS parser to handle that format.
- Try a different topic to confirm the parser works generally.
Example fix
// before
const items = parseRssItems(xml);
// after
let items = parseRssItems(xml);
if (!items.length) items = parseAtomEntries(xml); // fallback for Atom feeds
if (!items.length) throw new EmptyResultError('bbc topic', `BBC ${raw} feed returned no items.`); Defensive patterns
Strategy: fallback
Validate before calling
// after fetch: sanity-check the XML has items before full parse
if (!/<item[\s>]/.test(xml) && !/<entry[\s>]/.test(xml)) throw new Error('feed contains no items'); Type guard
const xmlHasItems = (xml) => typeof xml === 'string' && /<(item|entry)[\s>]/.test(xml);
Try / catch
try {
const items = await cli.run(['bbc','topic', topic]);
} catch (e) {
if (e.name === 'EmptyResultError') {
// fall back to another topic or cached headlines
}
} Prevention
- Retry transient empty feeds after a short delay
- Support both RSS <item> and Atom <entry> parsing
- Keep a cached copy of recent headlines as fallback
- Verify feed XML directly at feeds.bbci.co.uk when debugging
When it happens
Trigger: `bbc topic <valid-topic>` where BBC's feed returns valid XML with no <item> elements — new/low-traffic topics, feed temporarily cleared, or XML whose structure the parser doesn't recognize.
Common situations: BBC deploys a feed with only <entry> (Atom) elements instead of <item>, brand-new topic feeds with no published stories yet, transient BBC publishing glitches, parser not handling namespaces (e.g. media:rss extensions breaking item extraction).
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Medium tag "${tag}" RSS feed has no items.
- ${label} request failed: ${err?.message ?? err}
- NOT_FOUND
- NOT_FOUND
- The selected players were not both present in the resolved m
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a22b68cfafb4e346.
Report an issue: GitHub.