sansan0/TrendRadar · warning · DataNotFoundError

DATA_NOT_FOUND

DATA_NOT_FOUND

Error message

未找到相关新闻({time_desc})

What it means

DataNotFoundError from the news-collection loop in analytics.py: after walking each date from start to end (skipping days whose per-day read raises DataNotFoundError), all_news_items is still empty. time_desc renders '今天' when start==end, else the explicit date span. Code DATA_NOT_FOUND.

Source

Thrown at mcp_server/tools/analytics.py:763

                            }

                            # 条件性添加 URL 字段
                            if include_url:
                                news_item["url"] = info.get("url", "")
                                news_item["mobileUrl"] = info.get("mobileUrl", "")

                            all_news_items.append(news_item)

                except DataNotFoundError:
                    # 该日期没有数据,继续下一天
                    pass

                # 下一天
                current_date += timedelta(days=1)

            if not all_news_items:
                time_desc = "今天" if start_date == end_date else f"{start_date.strftime('%Y-%m-%d')} 至 {end_date.strftime('%Y-%m-%d')}"
                raise DataNotFoundError(
                    f"未找到相关新闻({time_desc})",
                    suggestion="请尝试其他话题、日期范围或平台"
                )

            # 去重(同一标题只保留一次)
            unique_news = {}
            for item in all_news_items:
                key = f"{item['platform']}::{item['title']}"
                if key not in unique_news:
                    unique_news[key] = item
                else:
                    # 合并 ranks(如果同一新闻在多天出现)
                    existing = unique_news[key]
                    existing["ranks"].extend(item["ranks"])
                    existing["count"] = len(existing["ranks"])

            deduplicated_news = list(unique_news.values())

View on GitHub (pinned to 8ee26026ba)

Solutions

  1. Widen the date range or drop the platforms filter.
  2. Use a broader/shorter topic term that is more likely to be a title substring.
  3. Confirm crawled data exists for at least some days in the range (see the parser-level DATA_NOT_FOUND for how per-day reads work).
  4. If expecting today's data, verify the crawler ran today.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    news = tools._collect_news(topic, start, end, platforms)
except DataNotFoundError:
    news = []  # render an explicit 'no coverage' state instead of propagating

Prevention

When it happens

Trigger: Searching a topic that appears in no titles during the range; range entirely composed of days with no crawled data; platform filter excluding every platform that mentioned the topic; overly specific topic phrasing that must match title text.

Common situations: Hot-topic analysis for a niche keyword; historical ranges predating the first crawl; combining a narrow date_range with a platforms filter that removes the only relevant source; crawler outage over the whole window.

Related errors


AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15). Data as JSON: /api/errors/120d4fdaffa585ba. Report an issue: GitHub.