jackwener/OpenCLI · warning · CliError

NOT_FOUND

NOT_FOUND

Error message

No trending data found

What it means

The google trends command throws this CliError with code NOT_FOUND when the trending RSS feed fetches successfully but parseRssItems returns zero items. It indicates the feed is empty or unparseable for the requested region, suggesting a different region code.

Source

Thrown at clis/google/trends.js:31

    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'region', default: 'US', help: 'Region code (e.g. US, CN, JP)' },
        { name: 'limit', type: 'int', default: 20, help: 'Number of results' },
    ],
    columns: ['title', 'traffic', 'date'],
    func: async (args) => {
        const limit = Math.max(1, Math.min(Number(args.limit), 100));
        const region = encodeURIComponent(args.region);
        const url = `https://trends.google.com/trending/rss?geo=${region}`;
        const resp = await fetch(url);
        if (!resp.ok) {
            throw new CliError('FETCH_ERROR', `HTTP ${resp.status}`, 'Check your network connection or region code');
        }
        const xml = await resp.text();
        const items = parseRssItems(xml, ['title', 'pubDate', 'ht:approx_traffic']);
        if (!items.length) {
            throw new CliError('NOT_FOUND', 'No trending data found', 'Try a different region code');
        }
        return items.slice(0, limit).map(item => ({
            title: item['title'],
            traffic: item['ht:approx_traffic'], // raw string e.g. "1,000,000+", no numeric conversion
            date: item['pubDate'],
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Try a major region code like US or GB which reliably has trending data
  2. Fetch the RSS URL in a browser to see if items exist but parsing fails
  3. Update parseRssItems / field names if Google changed the feed format
  4. Retry later if the feed is transiently empty
  5. Validate the geo code to ensure it maps to a region with a trending feed

Example fix

// before
if (!items.length) throw new CliError('NOT_FOUND', 'No trending data found', 'Try a different region code');
// after
if (!items.length && fallbackRegions.length) {
  for (const geo of fallbackRegions) { /* retry with 'US', 'GB' ... */ }
}
Defensive patterns

Strategy: fallback

Validate before calling

// validate region before invoking
if (!/^[A-Z]{2}$/.test(args.region || '')) throw new Error('region must be an ISO country code');

Type guard

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

Try / catch

try {
  return await trendsCommand.func(args);
} catch (e) {
  if (e.code === 'NOT_FOUND') {
    return trendsCommand.func({...args, region: 'US'}); // fallback to a major region
  }
  throw e;
}

Prevention

When it happens

Trigger: A 200 response from the trending RSS endpoint whose XML contains no <item> elements — regions with no trending data, an empty localized feed, or a feed format change that parseRssItems can no longer parse.

Common situations: Choosing a small region/geo code where Trends publishes no trending list; Google changing the trending RSS structure so items aren't extracted; a transient empty feed during Google-side updates; fields renamed (e.g. 'ht:approx_traffic') breaking parsing silently.

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