datawhalechina/hello-agents · error · HTTPException

未找到该次分析记录

Error message

未找到该次分析记录

What it means

HTTP 404 raised by GET /health/report_runs/{task_id}/observability when get_report_run(task_id.strip()) finds no row. Observability data (per-agent traces) is persisted with the report_run for new tasks; an unknown, typo'd, or pre-feature task_id yields this 404.

Source

Thrown at Co-creation-projects/Shawnxyxy-HealthRecordAgent/backend/api/routes/health.py:106

@router.get("/health/report_runs/{task_id}")
async def report_run_detail(task_id: str):
    row = get_report_run(task_id)
    if not row:
        return {"error": "未找到该次分析记录(可能尚未落库或 task_id 无效)"}
    return row


@router.get("/health/report_runs/{task_id}/observability")
async def report_run_observability(
    task_id: str, include_raw_trace: bool = False
):
    """
    阶段 3:体检分析可观测性 — 各 Agent trace 已随 report_runs 持久化(新产生任务)。
    `include_raw_trace=true` 时返回完整 trace(体积可能较大)。
    """
    row = get_report_run(task_id.strip())
    if not row:
        raise HTTPException(status_code=404, detail="未找到该次分析记录")
    return build_report_observability(row, include_raw_trace=include_raw_trace)

View on GitHub (pinned to 606a07d341)

Solutions

  1. Submit a new analysis via POST /health/analysis and use the freshly returned task_id.
  2. Verify the task exists via the report-run status/detail endpoint before requesting observability.
  3. Check for whitespace around the uuid if copy-pasted.

Example fix

# before
requests.get(f'{base}/health/report_runs/bad-id/observability')  # 404

# after
task_id = requests.post(f'{base}/health/analysis', json={...}).json()['task_id']
requests.get(f'{base}/health/report_runs/{task_id}/observability')
Defensive patterns

Strategy: validation

Validate before calling

tid = task_id.strip()
if not requests.get(f"{base}/health/report_runs/{tid}").ok:
    raise LookupError("task unknown; submit a new /health/analysis first")

Try / catch

try:
    obs = requests.get(f"{base}/health/report_runs/{tid}/observability").json()
except HTTPError as e:
    if e.response.status_code == 404:
        obs = None  # task predates trace persistence or unknown
    else:
        raise

Prevention

When it happens

Trigger: Polling the observability endpoint with a task_id that was never returned by POST /health/analysis, a truncated uuid, or a task created before trace persistence was added.

Common situations: Old task ids from before the observability feature; client losing/corrupting the task_id; in-memory store reset between submit and observe.

Related errors


AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14). Data as JSON: /api/errors/385a48989919d342. Report an issue: GitHub.