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
- Widen the date range or drop the platforms filter.
- Use a broader/shorter topic term that is more likely to be a title substring.
- 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).
- 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
- Loosen platform filters and widen date ranges when coverage is thin.
- Use broad topic terms likely to appear verbatim in headlines.
- Treat this as an empty-result condition in the UI, not an error.
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
- 日期表达式不能为空
- date_range JSON 解析失败: {e}
- 无法识别的日期表达式: {stripped}
- date_range 必须是字典类型、日期字符串或有效的JSON字符串
- date_range 必须包含 start 和 end 字段
AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15).
Data as JSON: /api/errors/120d4fdaffa585ba.
Report an issue: GitHub.