{"record":{"id":"06bf09ccc5e8768f","repo":"datawhalechina/hello-agents","slug":"no-report-found-for-incident-id-call-post-in","errorCode":null,"errorMessage":"No report found for '{incident_id}'. Call POST /incidents/investigate first.","messagePattern":"No report found for '(.+?)'\\. Call POST /incidents/investigate first\\.","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"Co-creation-projects/zjzhou-SREOnCallAgent/src/api/main.py","lineNumber":81,"sourceCode":"        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(\n            status_code=404,\n            detail=f\"No report found for '{incident_id}'. Call POST /incidents/investigate first.\",\n        )\n    return {\n        \"incident_id\": incident_id,\n        \"report\": _report_store[incident_id][\"report\"],\n    }\n","sourceCodeStart":63,"sourceCodeEnd":89,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/zjzhou-SREOnCallAgent/src/api/main.py#L63-L89","documentation":"FastAPI HTTPException raised by the GET /incidents/{incident_id}/report endpoint when the given incident_id is not present in the in-memory _report_store dict. This app keeps generated post-mortem reports only in a process-local dictionary populated by POST /incidents/investigate, so a lookup miss means either the investigation never ran in this process or the process restarted and lost its state.","triggerScenarios":"Calling GET /incidents/{id}/report before POST /incidents/investigate for the same id; calling GET after the server process restarted (the _report_store dict is wiped); using a typo'd or different incident_id than the one returned by the investigate call.","commonSituations":"Dev restarts uvicorn with --reload between the two calls and loses the store; frontend polls the report endpoint before the async investigation finishes; copy-pasting an incident_id from a previous run/session.","solutions":["Run POST /incidents/investigate with the same incident_id first, then GET the report","If the server reloaded or restarted, re-run the investigation — the store is in-memory only and does not survive restarts","Verify the incident_id string matches exactly (whitespace/case) what you sent to POST /incidents/investigate","For durability, back _report_store with a database or file instead of a dict"],"exampleFix":"# before\nGET /incidents/inc-123/report   # 404: never investigated in this process\n\n# after\nPOST /incidents/investigate {\"incident_id\": \"inc-123\", ...}\nGET /incidents/inc-123/report","handlingStrategy":"validation","validationCode":"import requests\n\nh = requests.get(f'{BASE}/incidents/{iid}/report')\nif h.status_code == 404:\n    # run investigation first, then re-fetch\n    requests.post(f'{BASE}/incidents/investigate', json={'incident_id': iid, ...})\nreport = requests.get(f'{BASE}/incidents/{iid}/report').json()","typeGuard":null,"tryCatchPattern":"try:\n    report = get_report(iid)\nexcept HTTPException as e:\n    if e.status_code == 404:\n        investigate(iid)  # then retry once\n    else:\n        raise","preventionTips":["Always chain POST /incidents/investigate before the report GET for a new incident_id","Treat server restarts as invalidating all previous incident_ids (in-memory store)","Return/store the incident_id from the investigate response instead of retyping it"],"tags":["fastapi","http-404","state-management","api"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}