{"record":{"id":"cc5dc6efd6fb9bff","repo":"HKUDS/Vibe-Trading","slug":"invalid-job-id","errorCode":null,"errorMessage":"invalid job_id","messagePattern":"invalid job_id","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":575,"sourceCode":"                            job[\"_finished_at\"] = time.time()\n\n        task = asyncio.create_task(_runner())\n        _RUNNING_TASKS.add(task)\n        task.add_done_callback(_RUNNING_TASKS.discard)\n        return {\"status\": \"ok\", \"job_id\": job_id}\n\n    # -----------------------------------------------------------------------\n    # GET /alpha/bench/{job_id}/stream\n    # -----------------------------------------------------------------------\n\n    @app.get(\n        \"/alpha/bench/{job_id}/stream\",\n        dependencies=[Depends(require_event_stream_auth)],\n    )\n    async def stream_bench(job_id: str, request: Request) -> StreamingResponse:\n        \"\"\"SSE: progress / result / done / error until the job terminates.\"\"\"\n        if not _JOB_ID_RE.fullmatch(job_id or \"\"):\n            raise HTTPException(status_code=400, detail=\"invalid job_id\")\n        with _JOBS_LOCK:\n            if job_id not in ALPHA_BENCH_JOBS:\n                raise HTTPException(status_code=404, detail=f\"job {job_id} not found\")\n        return _job_event_stream(ALPHA_BENCH_JOBS, job_id, request, _result_for_wire)\n\n    # -----------------------------------------------------------------------\n    # POST /alpha/compare\n    # -----------------------------------------------------------------------\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","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L557-L593","documentation":"The optional market filter for the universe action is normalized (strip/lower) and must be exactly 'twse' or 'tpex'. Any other value raises this ValueError before the SQL conditions are built — there is no 'all markets' via a sentinel string; omit market entirely for unfiltered output.","triggerScenarios":"Calling execute(action='universe', market='TW') , 'taiex', 'otc', 'NYSE', or 'twse ' (handled by strip) — anything outside the two-element set fails. Mixed-case like 'TWSE' is fine due to .lower().","commonSituations":"Assuming OTC/over-the-counter aliases for TPEX; passing exchange codes from a US-market integration; LLM guessing 'taiwan' as the market name; upstream enum drifting from the tool's.","solutions":["Use only 'twse' or 'tpex' (case-insensitive), or omit market to get both markets","Map aliases before calling: market={'otc':'tpex','taiex':'twse'}.get(raw.lower(), raw.lower())","Validate against the set at your API boundary: {'twse','tpex'}"],"exampleFix":"# before\nexecute(action='universe', market='OTC')\n# after\nexecute(action='universe', market='tpex')","handlingStrategy":"validation","validationCode":"ALLOWED = {'twse', 'tpex'}\nmarket = (raw or '').strip().lower() or None\nif market is not None and market not in ALLOWED:\n    raise ValueError(f\"market must be one of {sorted(ALLOWED)}, got {market!r}\")","typeGuard":"def is_valid_market(m) -> bool:\n    return m is None or str(m).strip().lower() in {'twse', 'tpex'}","tryCatchPattern":"try:\n    tool.execute(action='universe', market=market)\nexcept ValueError as e:\n    if 'market must be twse or tpex' in str(e):\n        result = tool.execute(action='universe')  # unfiltered fallback\n    else:\n        raise","preventionTips":["Normalize case and validate against the enum at the boundary","Omit market entirely when you want both exchanges"],"tags":["python","validation","enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}