{"record":{"id":"5d066db334269870","repo":"jackwener/OpenCLI","slug":"not-found-5d066d","errorCode":"NOT_FOUND","errorMessage":"No trending data found","messagePattern":"No trending data found","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"warning","filePath":"clis/google/trends.js","lineNumber":31,"sourceCode":"    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'region', default: 'US', help: 'Region code (e.g. US, CN, JP)' },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of results' },\n    ],\n    columns: ['title', 'traffic', 'date'],\n    func: async (args) => {\n        const limit = Math.max(1, Math.min(Number(args.limit), 100));\n        const region = encodeURIComponent(args.region);\n        const url = `https://trends.google.com/trending/rss?geo=${region}`;\n        const resp = await fetch(url);\n        if (!resp.ok) {\n            throw new CliError('FETCH_ERROR', `HTTP ${resp.status}`, 'Check your network connection or region code');\n        }\n        const xml = await resp.text();\n        const items = parseRssItems(xml, ['title', 'pubDate', 'ht:approx_traffic']);\n        if (!items.length) {\n            throw new CliError('NOT_FOUND', 'No trending data found', 'Try a different region code');\n        }\n        return items.slice(0, limit).map(item => ({\n            title: item['title'],\n            traffic: item['ht:approx_traffic'], // raw string e.g. \"1,000,000+\", no numeric conversion\n            date: item['pubDate'],\n        }));\n    },\n});\n","sourceCodeStart":13,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/google/trends.js#L13-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Try a major region code like US or GB which reliably has trending data","Fetch the RSS URL in a browser to see if items exist but parsing fails","Update parseRssItems / field names if Google changed the feed format","Retry later if the feed is transiently empty","Validate the geo code to ensure it maps to a region with a trending feed"],"exampleFix":"// before\nif (!items.length) throw new CliError('NOT_FOUND', 'No trending data found', 'Try a different region code');\n// after\nif (!items.length && fallbackRegions.length) {\n  for (const geo of fallbackRegions) { /* retry with 'US', 'GB' ... */ }\n}","handlingStrategy":"fallback","validationCode":"// validate region before invoking\nif (!/^[A-Z]{2}$/.test(args.region || '')) throw new Error('region must be an ISO country code');","typeGuard":"function hasTrendingItems(items) {\n  return Array.isArray(items) && items.length > 0;\n}","tryCatchPattern":"try {\n  return await trendsCommand.func(args);\n} catch (e) {\n  if (e.code === 'NOT_FOUND') {\n    return trendsCommand.func({...args, region: 'US'}); // fallback to a major region\n  }\n  throw e;\n}","preventionTips":["Default to major regions (US, GB) known to publish trending data","Fall back to alternate regions when a small geo is empty","Monitor Google's feed format for parsing breakage","Retry later — feeds can be transiently empty during updates"],"tags":["rss","empty-result","google","trends"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}