{"record":{"id":"385a48989919d342","repo":"datawhalechina/hello-agents","slug":"error-385a48","errorCode":null,"errorMessage":"未找到该次分析记录","messagePattern":"未找到该次分析记录","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"Co-creation-projects/Shawnxyxy-HealthRecordAgent/backend/api/routes/health.py","lineNumber":106,"sourceCode":"@router.get(\"/health/report_runs/{task_id}\")\nasync def report_run_detail(task_id: str):\n    row = get_report_run(task_id)\n    if not row:\n        return {\"error\": \"未找到该次分析记录（可能尚未落库或 task_id 无效）\"}\n    return row\n\n\n@router.get(\"/health/report_runs/{task_id}/observability\")\nasync def report_run_observability(\n    task_id: str, include_raw_trace: bool = False\n):\n    \"\"\"\n    阶段 3：体检分析可观测性 — 各 Agent trace 已随 report_runs 持久化（新产生任务）。\n    `include_raw_trace=true` 时返回完整 trace（体积可能较大）。\n    \"\"\"\n    row = get_report_run(task_id.strip())\n    if not row:\n        raise HTTPException(status_code=404, detail=\"未找到该次分析记录\")\n    return build_report_observability(row, include_raw_trace=include_raw_trace)","sourceCodeStart":88,"sourceCodeEnd":107,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/Shawnxyxy-HealthRecordAgent/backend/api/routes/health.py#L88-L107","documentation":"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.","triggerScenarios":"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.","commonSituations":"Old task ids from before the observability feature; client losing/corrupting the task_id; in-memory store reset between submit and observe.","solutions":["Submit a new analysis via POST /health/analysis and use the freshly returned task_id.","Verify the task exists via the report-run status/detail endpoint before requesting observability.","Check for whitespace around the uuid if copy-pasted."],"exampleFix":"# before\nrequests.get(f'{base}/health/report_runs/bad-id/observability')  # 404\n\n# after\ntask_id = requests.post(f'{base}/health/analysis', json={...}).json()['task_id']\nrequests.get(f'{base}/health/report_runs/{task_id}/observability')","handlingStrategy":"validation","validationCode":"tid = task_id.strip()\nif not requests.get(f\"{base}/health/report_runs/{tid}\").ok:\n    raise LookupError(\"task unknown; submit a new /health/analysis first\")","typeGuard":null,"tryCatchPattern":"try:\n    obs = requests.get(f\"{base}/health/report_runs/{tid}/observability\").json()\nexcept HTTPError as e:\n    if e.response.status_code == 404:\n        obs = None  # task predates trace persistence or unknown\n    else:\n        raise","preventionTips":["Capture task_id from the /health/analysis response and use it verbatim.","Expect 404 for tasks created before observability persistence shipped.","Trim copy-pasted uuids of stray whitespace."],"tags":["fastapi","http-404","observability","health-api"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}