datawhalechina/hello-agents · error · HTTPException

{str(e)}

Error message

{str(e)}

What it means

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.

Source

Thrown at Co-creation-projects/zjzhou-SREOnCallAgent/src/api/main.py:63


@app.get("/incidents/fixtures")
def get_fixtures():
    """List all available sample incident IDs."""
    return {"incidents": list_incidents()}


@app.post("/incidents/investigate")
def investigate(req: InvestigateRequest):
    """
    Run the full triage → investigation → post-mortem pipeline for an incident.

    This runs synchronously (suitable for demo; upgrade to background task + SSE for prod).
    """
    try:
        load_incident(req.incident_id)  # Validate early
    except FileNotFoundError as e:
        raise HTTPException(status_code=404, detail=str(e))

    start = time.time()
    try:
        result = run_pipeline(req.incident_id, verbose=False)
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Pipeline error: {e}")

    elapsed = round(time.time() - start, 1)
    result["elapsed_seconds"] = elapsed
    _report_store[req.incident_id] = result
    return result


@app.get("/incidents/{incident_id}/report")
def get_report(incident_id: str):
    """Retrieve a previously generated post-mortem report."""
    if incident_id not in _report_store:
        raise HTTPException(

View on GitHub (pinned to 606a07d341)

Solutions

  1. Read the 404 detail — it lists available incident IDs; retry with one of them.
  2. Call the incidents listing endpoint (or check data/incidents/) before investigating.
  3. If deploying, ensure the data/incidents/*.json files ship with the API service.

Example fix

# before
resp = requests.post(f"{BASE}/incidents/investigate", json={"incident_id": "INC-9"})

# after
ids = requests.get(f"{BASE}/incidents").json()  # discover valid IDs
resp = requests.post(f"{BASE}/incidents/investigate", json={"incident_id": ids[0]})
Defensive patterns

Strategy: validation

Validate before calling

import requests

ids = requests.get(f"{BASE}/incidents", timeout=10).json()  # discover valid IDs
if req_incident_id not in ids:
    raise ValueError(f"unknown incident {req_incident_id}; choose from {ids}")
resp = requests.post(f"{BASE}/incidents/investigate", json={"incident_id": req_incident_id})

Try / catch

resp = requests.post(f"{BASE}/incidents/investigate", json={"incident_id": iid})
if resp.status_code == 404:
    available = resp.json()["detail"]  # includes the Available: list
    iid = parse_first_available(available)
    resp = requests.post(f"{BASE}/incidents/investigate", json={"incident_id": iid})
resp.raise_for_status()

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


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