{"record":{"id":"5ff5a27fc5a8bb6c","repo":"HKUDS/Vibe-Trading","slug":"too-many-running-comparisons-wait-for-one-to-fini","errorCode":null,"errorMessage":"too many running comparisons; wait for one to finish","messagePattern":"too many running comparisons; wait for one to finish","errorType":"http","errorClass":"HTTPException","httpStatus":429,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":601,"sourceCode":"    # -----------------------------------------------------------------------\n\n    @app.post(\n        \"/alpha/compare\",\n        status_code=202,\n        dependencies=[Depends(require_auth)],\n    )\n    async def kick_off_compare(payload: CompareRequest) -> dict[str, Any]:\n        \"\"\"Queue a background head-to-head comparison and return a job_id.\"\"\"\n        from src.tools.alpha_bench_tool import _parse_period\n\n        try:\n            _parse_period(payload.period)\n        except ValueError as exc:\n            raise HTTPException(status_code=400, detail=f\"invalid period: {exc}\")\n\n        sem = _get_compare_semaphore()\n        if sem.locked() or getattr(sem, \"_value\", MAX_CONCURRENT_COMPARES) <= 0:\n            raise HTTPException(\n                status_code=429,\n                detail=\"too many running comparisons; wait for one to finish\",\n            )\n\n        _prune_old_jobs()\n\n        job_id = uuid.uuid4().hex\n        with _JOBS_LOCK:\n            ALPHA_COMPARE_JOBS[job_id] = {\n                \"job_id\": job_id,\n                \"status\": \"queued\",\n                \"alpha_ids\": payload.alpha_ids,\n                \"universe\": payload.universe,\n                \"period\": payload.period,\n                \"sort\": payload.sort,\n                \"created_at\": _now_iso(),\n                \"progress\": {\"n_done\": 0, \"n_total\": len(payload.alpha_ids), \"current_alpha_id\": None},\n                \"result\": None,","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L583-L619","documentation":"load_dataframe is the entry point of the trade-journal parsing stack; it takes a filesystem path and raises FileNotFoundError when Path(path).exists() is false. Both .xlsx/.xls and .csv routes sit behind this check, so any missing file fails here regardless of format.","triggerScenarios":"Calling parse_file('trades.csv') when the file is absent, in a different CWD, already moved/deleted by a prior step, or when the path contains typos, unexpanded '~', or wrong separators. Also triggered in tests via tmp paths that were never written.","commonSituations":"Upload handlers that store the file then race with deletion; relative paths resolved against a different working directory; user-supplied Windows-style paths on POSIX; cron/airflow tasks whose upstream file-producing step failed silently.","solutions":["Check existence before parsing: if not Path(p).is_file(): raise/skip early","Expand and absolutize user paths: p = Path(user_path).expanduser().resolve()","Verify the producing step succeeded before invoking the parser in pipelines"],"exampleFix":"# before\nparse_file('~/uploads/trades.csv')  # '~' not expanded by Path.exists\n# after\nfrom pathlib import Path\np = Path('~/uploads/trades.csv').expanduser().resolve()\nassert p.is_file(), f'missing {p}'\nparse_file(str(p))","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(user_path).expanduser().resolve()\nif not p.is_file():\n    raise FileNotFoundError(f'upload not found: {p}')\ndf = load_dataframe(str(p))","typeGuard":"def is_readable_file(p) -> bool:\n    from pathlib import Path\n    return Path(p).expanduser().is_file()","tryCatchPattern":"try:\n    df = load_dataframe(path)\nexcept FileNotFoundError:\n    path = locate_upload_elsewhere()  # search/re-download\n    df = load_dataframe(path)","preventionTips":["expanduser()+resolve() all user-supplied paths before checking existence","In upload flows, parse immediately after persisting, or hold an open handle"],"tags":["python","missing-file","file-path"],"backgroundTag":"file-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}