{"record":{"id":"7babc141e04b6db1","repo":"datawhalechina/hello-agents","slug":"str-e-7babc1","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"Co-creation-projects/zjzhou-SREOnCallAgent/src/api/main.py","lineNumber":63,"sourceCode":"\n\n@app.get(\"/incidents/fixtures\")\ndef get_fixtures():\n    \"\"\"List all available sample incident IDs.\"\"\"\n    return {\"incidents\": list_incidents()}\n\n\n@app.post(\"/incidents/investigate\")\ndef investigate(req: InvestigateRequest):\n    \"\"\"\n    Run the full triage → investigation → post-mortem pipeline for an incident.\n\n    This runs synchronously (suitable for demo; upgrade to background task + SSE for prod).\n    \"\"\"\n    try:\n        load_incident(req.incident_id)  # Validate early\n    except FileNotFoundError as e:\n        raise HTTPException(status_code=404, detail=str(e))\n\n    start = time.time()\n    try:\n        result = run_pipeline(req.incident_id, verbose=False)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Pipeline error: {e}\")\n\n    elapsed = round(time.time() - start, 1)\n    result[\"elapsed_seconds\"] = elapsed\n    _report_store[req.incident_id] = result\n    return result\n\n\n@app.get(\"/incidents/{incident_id}/report\")\ndef get_report(incident_id: str):\n    \"\"\"Retrieve a previously generated post-mortem report.\"\"\"\n    if incident_id not in _report_store:\n        raise HTTPException(","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/zjzhou-SREOnCallAgent/src/api/main.py#L45-L81","documentation":"The /incidents/investigate endpoint converts FileNotFoundError from load_incident into HTTPException(404) with detail=str(e). The detail therefore carries the pipeline's message including the 'Available: [...]' incident list. It fires on the early validation call, before any triage work starts, so a 404 here always means 'unknown incident ID', never a pipeline failure.","triggerScenarios":"POST /incidents/investigate with {\"incident_id\": \"typo-or-unknown\"}; IDs with wrong case; IDs with '.json' appended; incident data files missing from the deployed data/incidents/ directory.","commonSituations":"Client hardcodes an incident ID that doesn't exist in this deployment; data volume not mounted in the container; environment mismatch between dev (full dataset) and prod (subset).","solutions":["Read the 404 detail — it lists available incident IDs; retry with one of them.","Call the incidents listing endpoint (or check data/incidents/) before investigating.","If deploying, ensure the data/incidents/*.json files ship with the API service."],"exampleFix":"# before\nresp = requests.post(f\"{BASE}/incidents/investigate\", json={\"incident_id\": \"INC-9\"})\n\n# after\nids = requests.get(f\"{BASE}/incidents\").json()  # discover valid IDs\nresp = requests.post(f\"{BASE}/incidents/investigate\", json={\"incident_id\": ids[0]})","handlingStrategy":"validation","validationCode":"import requests\n\nids = requests.get(f\"{BASE}/incidents\", timeout=10).json()  # discover valid IDs\nif req_incident_id not in ids:\n    raise ValueError(f\"unknown incident {req_incident_id}; choose from {ids}\")\nresp = requests.post(f\"{BASE}/incidents/investigate\", json={\"incident_id\": req_incident_id})","typeGuard":null,"tryCatchPattern":"resp = requests.post(f\"{BASE}/incidents/investigate\", json={\"incident_id\": iid})\nif resp.status_code == 404:\n    available = resp.json()[\"detail\"]  # includes the Available: list\n    iid = parse_first_available(available)\n    resp = requests.post(f\"{BASE}/incidents/investigate\", json={\"incident_id\": iid})\nresp.raise_for_status()","preventionTips":["Cache the incident list from the listing endpoint and validate IDs client-side.","Normalize user input (case, strip '.json') before sending.","In deployments, mount the data/incidents volume and health-check its contents.","Treat 404 as an input problem — do not retry the same ID unchanged."],"tags":["fastapi","http-404","rest","sre"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}