HKUDS/Vibe-Trading · error · HTTPException
{str(e)}
Error message
{str(e)} What it means
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.
Source
Thrown at agent/src/api/swarm_routes.py:105
from src.swarm.presets import list_presets
return list_presets()
@app.post("/swarm/runs", dependencies=[Depends(require_auth)])
async def create_swarm_run(payload: dict, http_request: Request):
"""Start a swarm run: body must include preset_name and user_vars."""
runtime = _get_swarm_runtime()
preset_name = payload.get("preset_name", "")
user_vars = payload.get("user_vars", {})
try:
run = runtime.start_run(
preset_name,
user_vars,
include_shell_tools=_host_shell_tools_enabled_for_request(http_request),
)
return {"id": run.id, "status": run.status.value, "preset_name": run.preset_name}
except FileNotFoundError as e:
raise HTTPException(status_code=404, detail=str(e))
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
@app.get("/swarm/runs", dependencies=[Depends(require_auth)])
async def list_swarm_runs(limit: int = Query(20, ge=1, le=100)):
"""List swarm runs (newest first), reconciled."""
runtime = _get_swarm_runtime()
runs = runtime._store.list_runs(limit=limit)
items = []
for r in runs:
# Reconcile each row: a zombie running run will be auto-finalized so
# the dashboard never shows a "running" stuck row.
reconciled = runtime._store.reconcile_run(r, write=True)
items.append(
{
"id": reconciled.id,
"preset_name": reconciled.preset_name,
"status": reconciled.status.value,View on GitHub (pinned to 80ffdda44c)
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
Example fix
// before
{"preset_name": "my-preset "}
// after
{"preset_name": "my-preset"} Defensive patterns
Strategy: validation
Validate before calling
presets = client.get("/swarm/presets").json() # or list preset files
assert payload["preset_name"] in {p["name"] for p in presets}, "unknown preset" Type guard
def is_known_preset(name: str, presets: list[dict]) -> bool:
return any(p["name"] == name for p in presets) Try / catch
try:
run = client.post("/swarm/runs", json=payload)
except HTTPError as e:
if e.response.status_code == 404:
show("Preset not found: pick one from the preset list")
else:
raise Prevention
- 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
When it happens
Trigger: POST /swarm/runs with a preset_name that doesn't match any preset file (typo, deleted preset, wrong presets directory).
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Run directory not found: {rd.name}
- Task not found: {path.name}
- Session {session_id} not found
- No current goal
- Media file not found: {media_path}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/3b3d951c1c1b66ca.
Report an issue: GitHub.