{"record":{"id":"3b3d951c1c1b66ca","repo":"HKUDS/Vibe-Trading","slug":"str-e","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"agent/src/api/swarm_routes.py","lineNumber":105,"sourceCode":"        from src.swarm.presets import list_presets\n\n        return list_presets()\n\n    @app.post(\"/swarm/runs\", dependencies=[Depends(require_auth)])\n    async def create_swarm_run(payload: dict, http_request: Request):\n        \"\"\"Start a swarm run: body must include preset_name and user_vars.\"\"\"\n        runtime = _get_swarm_runtime()\n        preset_name = payload.get(\"preset_name\", \"\")\n        user_vars = payload.get(\"user_vars\", {})\n        try:\n            run = runtime.start_run(\n                preset_name,\n                user_vars,\n                include_shell_tools=_host_shell_tools_enabled_for_request(http_request),\n            )\n            return {\"id\": run.id, \"status\": run.status.value, \"preset_name\": run.preset_name}\n        except FileNotFoundError as e:\n            raise HTTPException(status_code=404, detail=str(e))\n        except ValueError as e:\n            raise HTTPException(status_code=400, detail=str(e))\n\n    @app.get(\"/swarm/runs\", dependencies=[Depends(require_auth)])\n    async def list_swarm_runs(limit: int = Query(20, ge=1, le=100)):\n        \"\"\"List swarm runs (newest first), reconciled.\"\"\"\n        runtime = _get_swarm_runtime()\n        runs = runtime._store.list_runs(limit=limit)\n        items = []\n        for r in runs:\n            # Reconcile each row: a zombie running run will be auto-finalized so\n            # the dashboard never shows a \"running\" stuck row.\n            reconciled = runtime._store.reconcile_run(r, write=True)\n            items.append(\n                {\n                    \"id\": reconciled.id,\n                    \"preset_name\": reconciled.preset_name,\n                    \"status\": reconciled.status.value,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/swarm_routes.py#L87-L123","documentation":"create_swarm_run maps FileNotFoundError to 404 when the requested swarm preset cannot be found on disk. The preset name from the request is resolved against the presets directory; a missing or misspelled preset file raises this from the run creation call.","triggerScenarios":"POST /swarm/runs with a preset_name that doesn't match any preset file (typo, deleted preset, wrong presets directory).","commonSituations":"Renaming or removing preset YAML/JSON files without updating callers, running in an environment where the presets dir isn't mounted, or preset name casing/spacing mismatch.","solutions":["Verify the preset exists: list available presets via the API or presets directory and correct preset_name","Check the presets directory path/config the server resolves against","Ensure preset files are deployed/mounted in the environment the API runs in"],"exampleFix":"// before\n{\"preset_name\": \"my-preset \"}\n// after\n{\"preset_name\": \"my-preset\"}","handlingStrategy":"validation","validationCode":"presets = client.get(\"/swarm/presets\").json()  # or list preset files\nassert payload[\"preset_name\"] in {p[\"name\"] for p in presets}, \"unknown preset\"","typeGuard":"def is_known_preset(name: str, presets: list[dict]) -> bool:\n    return any(p[\"name\"] == name for p in presets)","tryCatchPattern":"try:\n    run = client.post(\"/swarm/runs\", json=payload)\nexcept HTTPError as e:\n    if e.response.status_code == 404:\n        show(\"Preset not found: pick one from the preset list\")\n    else:\n        raise","preventionTips":["Fetch the preset list before showing a preset picker","Validate preset_name against deployed presets in CI","Treat FileNotFoundError detail as a preset-name problem first"],"tags":["http-404","swarm","preset-not-found","file-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}