ZhuLinsen/daily_stock_analysis · error · RuntimeError
大盘复盘未返回可持久化报告
Error message
大盘复盘未返回可持久化报告
What it means
The market-review API background task raises RuntimeError('大盘复盘未返回可持久化报告') when run_market_review(...) (src/core/market_review.py:174) returns a falsy report — the pipeline swallowed its internal errors and produced no persistable text (analysis.py:160-167). run_market_review itself wraps the whole multi-region review in a broad try/except and returns None on failure, so this RuntimeError is the API layer refusing to persist an empty result.
Source
Thrown at api/v1/endpoints/analysis.py:167
"analyzer": analyzer,
"search_service": search_service,
"config": runtime_config,
"send_notification": send_notification,
"override_region": effective_region,
"return_structured": True,
"trigger_source": "api",
}
if query_id:
review_kwargs["query_id"] = query_id
logger.info(
"[MarketReview] component=market_review action=background_start "
"trigger_source=api task_id=%s region=%s",
query_id or "-",
effective_region,
)
report = run_market_review(**review_kwargs)
if not report:
raise RuntimeError("大盘复盘未返回可持久化报告")
if hasattr(report, "report"):
return {
"result": report.report,
"market_review_payload": getattr(report, "market_review_payload", None),
"region": effective_region,
}
return {"result": report, "region": effective_region}
finally:
_release_market_review_lock(lock_token)
def _coalesce_text(*values: Any) -> Optional[str]:
for value in values:
if value is None:
continue
text = str(value).strip()
if text:
return textView on GitHub (pinned to 5159bd72e8)
Solutions
- Inspect the server logs for the upstream [MarketReview] component errors — the RuntimeError here only tells you the report was empty, not why
- Verify LLM and search provider credentials (the same config used for stock analysis) and re-run a single-region market review to isolate the failing region
- Check data_provider health for the effective region (cn/us/hk) and retry after fixing connectivity
- If regions are partially failing, consider narrowing market_review_region to the healthy region so a partial report still persists
Defensive patterns
Strategy: try-catch
Try / catch
try:
result = trigger_market_review_api(payload)
except TaskFailed as e: # RuntimeError surfaced as task failure
if '未返回可持久化报告' in str(e):
# inspect server [MarketReview] logs; check LLM/search creds; narrow region; retry once
check_provider_credentials(); retry_with_single_region()
else:
raise Prevention
- Health-check LLM and search providers before scheduling market reviews
- Start with a single region (cn) and add us/hk once each proves it can persist a report
- Alert on empty-report outcomes so silent upstream failures are visible
- Keep market_review_region explicit in deployment config to avoid accidental multi-region blast radius
When it happens
Trigger: POST /analysis market-review style endpoint where every configured region's MarketAnalyzer.run_daily_review_with_snapshot() fails or returns empty (bad LLM/search credentials, upstream data provider outage); analyzer/search_service constructed with invalid config so report generation is skipped; notify-only or merge paths that suppress the report body under failure. Because a background lock (_release_market_review_lock in finally) serializes runs, the error surfaces as the task's failure result for the query_id/task_id.
Common situations: Expired or missing LLM API keys in the server env; data-provider fallback chain exhausted during a market holiday or data outage; region set to a market whose data source is unreachable from the deployment network; first run after upgrade where report template/language settings return empty strings.
Related errors
- extract_failed
- internal_error
- {call_name} 调用超过 {wait_seconds:g}s,已放弃等待
- {call_name} 调用进程未返回结果
- AkshareFetcher 不支持美股 {stock_code},请使用 YfinanceFetcher 获取正确的复
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/c6ca733eb126dd29.
Report an issue: GitHub.