{"record":{"id":"1136e92dfe0e3b61","repo":"abi/screenshot-to-code","slug":"no-runs-recorded","errorCode":null,"errorMessage":"No runs recorded","messagePattern":"No runs recorded","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"backend/routes/agent_runs.py","lineNumber":139,"sourceCode":"    return AgentRunSummary(**data)\n\n\ndef _directory_size_bytes(path: str) -> int:\n    total = 0\n    for root, _, files in os.walk(path):\n        for name in files:\n            try:\n                total += os.path.getsize(os.path.join(root, name))\n            except OSError:\n                continue\n    return total\n\n\ndef _fetch_run(run_id: str) -> AgentRunSummary:\n    if not RUN_ID_PATTERN.match(run_id):\n        raise HTTPException(status_code=400, detail=\"Invalid run id\")\n    if not os.path.isfile(get_agent_runs_db_path()):\n        raise HTTPException(status_code=404, detail=\"No runs recorded\")\n    conn = open_index_db()\n    try:\n        row = conn.execute(\n            f\"SELECT {', '.join(_RUN_COLUMNS)} FROM runs WHERE run_id = ?\",\n            (run_id,),\n        ).fetchone()\n    finally:\n        conn.close()\n    if row is None:\n        raise HTTPException(status_code=404, detail=\"Run not found\")\n    return _row_to_summary(row)\n\n\n@router.get(\"/agent-runs\", response_model=AgentRunListResponse)\nasync def list_agent_runs(limit: int = 200) -> AgentRunListResponse:\n    runs_directory = get_agent_runs_directory()\n    if not os.path.isfile(get_agent_runs_db_path()):\n        return AgentRunListResponse(","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/agent_runs.py#L121-L157","documentation":"Raised by _fetch_run() (404) when the SQLite index database returned by get_agent_runs_db_path() does not exist on disk. It means the backend has never recorded any agent run on this machine — the index DB is created lazily on the first run, not at startup. Note the sibling list endpoint GET /agent-runs returns an empty list in the same situation, so the detail endpoints are stricter than the list endpoint.","triggerScenarios":"Calling GET /agent-runs/{run_id} (or /output, /assets/...) on a fresh installation, or after the runs data directory was pruned/deleted, or when SCREENSHOT_TO_CODE_DATA_DIR (or the equivalent env var controlling the runs directory) points somewhere the DB was never created.","commonSituations":"Fresh clone/first launch before any generation run; the ~/.screenshot-to-code data dir was wiped; a changed data-dir env var between runs; pruning removed the DB file itself.","solutions":["Run one agent generation first so the indexer creates the DB, then retry.","Confirm the runs directory/db path the backend uses (call GET /agent-runs and read runs_directory from the response) and check the DB file exists there.","If the DB was deleted but run directories still exist, re-run whatever indexing/recording step your version provides, or restore the DB from backup.","If you moved the data directory via env var, restart the backend so paths resolve consistently."],"exampleFix":"# before\nresp = client.get(f\"/agent-runs/{run_id}/output\")  # 404 'No runs recorded'\n\n# after\nlisting = client.get(\"/agent-runs\").json()\nif not listing[\"runs\"]:\n    print(f\"no runs yet under {listing['runs_directory']}; run a generation first\")\nelse:\n    resp = client.get(f\"/agent-runs/{run_id}/output\")","handlingStrategy":"fallback","validationCode":"listing = client.get(\"/agent-runs\").json()\nif not listing[\"runs\"]:\n    # index DB absent; detail calls will 404 with 'No runs recorded'\n    raise SystemExit(\"no runs recorded yet — run a generation first\")","typeGuard":"def has_recorded_runs(listing: dict) -> bool:\n    \"\"\"True when the agent-runs index exists and holds at least one run.\"\"\"\n    return bool(listing.get(\"runs\"))","tryCatchPattern":"try:\n    detail = client.get(f\"/agent-runs/{run_id}\").raise_for_status().json()\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 404 and \"No runs recorded\" in e.response.text:\n        detail = None  # fresh install: nothing recorded yet\n    else:\n        raise","preventionTips":["Check GET /agent-runs for an empty list before hitting detail endpoints.","Run at least one generation before building tooling that reads run details.","Keep the data directory stable across backend restarts."],"tags":["fastapi","http-404","sqlite","state","agent-runs"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}