{"record":{"id":"ed87e59e59d92bd2","repo":"HKUDS/Vibe-Trading","slug":"unknown-sort-v-r-expected-one-of-sorted-valid","errorCode":null,"errorMessage":"unknown sort {v!r}; expected one of {sorted(_VALID_SORTS)}","messagePattern":"unknown sort (.+?); expected one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":216,"sourceCode":"                out.append(aid)\n        if len(out) < 2:\n            raise ValueError(\"need at least 2 distinct alpha_ids to compare\")\n        return out\n\n    @field_validator(\"universe\")\n    @classmethod\n    def _universe_known(cls, v: str) -> str:\n        if v not in _BENCH_UNIVERSES:\n            raise ValueError(\n                f\"unknown universe {v!r}; expected one of {sorted(_BENCH_UNIVERSES)}\"\n            )\n        return v\n\n    @field_validator(\"sort\")\n    @classmethod\n    def _sort_known(cls, v: str) -> str:\n        if v not in _VALID_SORTS:\n            raise ValueError(f\"unknown sort {v!r}; expected one of {sorted(_VALID_SORTS)}\")\n        return v\n\n\n# ---------------------------------------------------------------------------\n# Bench worker (runs in a thread; LLM-free, pandas-heavy)\n# ---------------------------------------------------------------------------\n\n\ndef _make_progress_cb(\n    job_id: str, jobs: dict[str, dict[str, Any]] = ALPHA_BENCH_JOBS\n) -> Callable[[int, int, str], None]:\n    \"\"\"Return an on_progress closure that updates the job entry in-place.\"\"\"\n\n    def _cb(n_done: int, n_total: int, alpha_id: str) -> None:\n        with _JOBS_LOCK:\n            job = jobs.get(job_id)\n            if job is None:\n                return","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L198-L234","documentation":"scaffold_connector refuses to overwrite: it resolves destination/<connector-id> and raises ValueError if that directory already exists, before creating anything. This prevents clobbering an existing connector with a fresh scaffold.","triggerScenarios":"Running connector init twice for the same id in the same destination; a previous scaffold (or manually created folder) with the same name exists.","commonSituations":"Re-running a setup script that scaffolds on every run; retrying after an interrupted init left the directory behind; forgetting a scaffold from an earlier session.","solutions":["Pick a different connector id or a different destination directory","If the existing directory is disposable, delete or rename it first","If it's an existing project, open it instead of re-scaffolding"],"exampleFix":"# before\nscaffold_connector(\"acme-broker\", Path(\"./connectors\"))  # ValueError: exists\n\n# after\nfrom pathlib import Path\ntarget = Path(\"./connectors/acme-broker\")\nif target.exists():\n    shutil.rmtree(target)  # only if disposable\nscaffold_connector(\"acme-broker\", Path(\"./connectors\"))","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef scaffold_target_free(destination: Path, connector_id: str) -> bool:\n    return not (destination.expanduser().resolve() / connector_id.strip().lower()).exists()","typeGuard":null,"tryCatchPattern":"try:\n    scaffold_connector(cid, dest)\nexcept ValueError as e:\n    if \"already exists\" in str(e):\n        print(f\"skipping scaffold, exists: {e}\")  # idempotent scripts\n    else:\n        raise","preventionTips":["Make setup scripts idempotent: check target.exists() before scaffolding","Use unique ids per experiment instead of reusing 'test'","Clean up scaffolds you no longer need"],"tags":["scaffold","filesystem","already-exists","trading"],"backgroundTag":"path-already-exists","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}