jackwener/OpenCLI · warning · CliError

NOT_FOUND

NOT_FOUND

Error message

No news articles found

What it means

The google news command throws this CliError with code NOT_FOUND when the RSS feed fetched successfully but parseRssItems produced zero items. It distinguishes an empty/valid feed from a network failure, prompting the user to change keyword or region.

Source

Thrown at clis/google/news.js:38

    ],
    columns: ['title', 'source', 'date', 'url'],
    func: async (args) => {
        const limit = Math.max(1, Math.min(Number(args.limit), 100));
        const lang = encodeURIComponent(args.lang);
        const region = encodeURIComponent(args.region);
        const ceid = `${args.region}:${args.lang}`;
        // Top stories or search
        const base = args.keyword
            ? `https://news.google.com/rss/search?q=${encodeURIComponent(args.keyword)}&hl=${lang}&gl=${region}&ceid=${ceid}`
            : `https://news.google.com/rss?hl=${lang}&gl=${region}&ceid=${ceid}`;
        const resp = await fetch(base);
        if (!resp.ok) {
            throw new CliError('FETCH_ERROR', `HTTP ${resp.status}`, 'Check your network connection');
        }
        const xml = await resp.text();
        const items = parseRssItems(xml, ['title', 'link', 'pubDate', 'source']);
        if (!items.length) {
            throw new CliError('NOT_FOUND', 'No news articles found', 'Try a different keyword or region');
        }
        return items.slice(0, limit).map(item => {
            // Extract source: prefer <source> element, fallback to parsing title
            let title = item['title'] || '';
            let source = item['source'] || '';
            if (!source) {
                const idx = title.lastIndexOf(' - ');
                if (idx !== -1) {
                    source = title.slice(idx + 3);
                    title = title.slice(0, idx);
                }
            }
            return {
                title,
                source,
                date: item['pubDate'] || '',
                url: item['link'] || '',
            };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Try a broader or different keyword
  2. Remove or change the region/lang parameters to a default (e.g. en-US) that has wider coverage
  3. Fetch the URL manually in a browser to confirm whether the feed itself is empty
  4. If items exist in the browser but not here, update parseRssItems to handle the current RSS format

Example fix

// before
if (!items.length) throw new CliError('NOT_FOUND', 'No news articles found', 'Try a different keyword or region');
// after
if (!items.length) {
  console.warn('No articles; retrying with default locale');
  items = parseRssItems(await (await fetch(baseDefaultLocale)).text(), ['title','link','pubDate','source']);
}
Defensive patterns

Strategy: fallback

Validate before calling

// pre-check keyword non-empty before invoking
if (!keyword || !keyword.trim()) throw new Error('keyword required');

Type guard

function isNonEmptyItems(items) {
  return Array.isArray(items) && items.length > 0;
}

Try / catch

try {
  return await newsCommand.func(args);
} catch (e) {
  if (e.code === 'NOT_FOUND') {
    return newsCommand.func({...args, keyword: undefined}); // fallback to top stories
  }
  throw e;
}

Prevention

When it happens

Trigger: A successful 200 response from news.google.com/rss whose XML contains no parseable <item> elements — e.g. a keyword with no matching articles for the chosen language/region, or a feed format change that breaks parseRssItems field extraction.

Common situations: Searching an obscure keyword combined with a restrictive gl/ceid locale that has no coverage; region code mismatch causing an empty localized feed; Google changing RSS item structure so the parser extracts nothing; very new topics with no indexed articles yet.

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


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