{"record":{"id":"6b8cf13b23f9d195","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-not-found","errorCode":null,"errorMessage":"alpha_id not found","messagePattern":"alpha_id not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":464,"sourceCode":"        }\n\n    # -----------------------------------------------------------------------\n    # GET /alpha/{alpha_id}\n    # -----------------------------------------------------------------------\n\n    @app.get(\"/alpha/{alpha_id}\", dependencies=[Depends(require_auth)])\n    async def get_alpha(alpha_id: str) -> dict[str, Any]:\n        \"\"\"Return alpha metadata + the source code of its zoo .py file.\"\"\"\n        if not _ALPHA_ID_RE.fullmatch(alpha_id or \"\"):\n            raise HTTPException(status_code=400, detail=\"invalid alpha_id\")\n\n        from src.factors.registry import RegistryError, get_default_registry\n\n        registry = get_default_registry()\n        try:\n            alpha = registry.get(alpha_id)\n        except KeyError:\n            raise HTTPException(\n                status_code=404,\n                detail={\"status\": \"error\", \"error\": \"alpha_id not found\"},\n            )\n\n        try:\n            source_code = registry.get_source(alpha_id)\n        except RegistryError as exc:\n            # Source-read failure is a degraded but recoverable case — log and\n            # surface a short placeholder. The reason here is a typed registry\n            # error (size cap or OS error from a known path), safe to expose.\n            logger.warning(\"failed to read source for %s: %s\", alpha_id, exc)\n            source_code = f\"# <source unavailable: {exc}>\"\n\n        return {\n            \"status\": \"ok\",\n            \"alpha\": {\n                \"id\": alpha.id,\n                \"zoo\": alpha.zoo,","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L446-L482","documentation":"Date parameters (start_date/end_date) are parsed with date.fromisoformat after str/strip. Any value that is not strict ISO YYYY-MM-DD raises this ValueError, with field_name telling you which parameter failed. Note fromisoformat in older Python (<3.11) also rejects 'YYYYMMDD' and other loose forms.","triggerScenarios":"Calling execute(action='history', start_date='2024/01/01'), end_date='20240131', '2024-1-5' (non-padded), or 'Jan 1 2024'. Only zero-padded YYYY-MM-DD such as '2024-01-31' parses.","commonSituations":"Frontend date pickers emitting slashes or timestamps; Excel/CSV dates in MM/DD/YYYY; LLM callers natural-language dates; passing datetime objects with time components that stringify to '2024-01-31 00:00:00' (rejected on Python <3.11).","solutions":["Normalize to ISO before calling: parsed=date.fromisoformat(x) then pass parsed.isoformat(), or datetime.strptime(x,'%m/%d/%Y').strftime('%Y-%m-%d')","Truncate datetimes: str(value)[:10] to drop the time component","Validate format client-side with regex ^\\d{4}-\\d{2}-\\d{2}$"],"exampleFix":"# before\nexecute(action='history', start_date='2024/01/01', end_date='2024/01/31')\n# after\nfrom datetime import datetime\nfmt=lambda s: datetime.strptime(s,'%Y/%m/%d').strftime('%Y-%m-%d')\nexecute(action='history', start_date=fmt('2024/01/01'), end_date=fmt('2024/01/31'))","handlingStrategy":"validation","validationCode":"from datetime import date, datetime\n\ndef to_iso(field_name, v):\n    if isinstance(v, datetime):\n        v = v.date()\n    if isinstance(v, date):\n        return v.isoformat()\n    return datetime.strptime(str(v).strip(), '%Y-%m-%d').date().isoformat()","typeGuard":"import re\ndef is_iso_date(s) -> bool:\n    return bool(re.fullmatch(r'\\d{4}-\\d{2}-\\d{2}', str(s).strip())) and __import__('datetime').date.fromisoformat(str(s).strip()) is not None","tryCatchPattern":"try:\n    tool.execute(action='history', start_date=sd, end_date=ed)\nexcept ValueError as e:\n    if 'must use YYYY-MM-DD format' in str(e):\n        sd, ed = to_iso('start_date', sd), to_iso('end_date', ed)\n        result = tool.execute(action='history', start_date=sd, end_date=ed)\n    else:\n        raise","preventionTips":["Always run date inputs through date.fromisoformat().isoformat() round-trip","Use format='YYYY-MM-DD' in frontend date pickers and JSON schema pattern ^\\d{4}-\\d{2}-\\d{2}$"],"tags":["python","validation","date-format","iso-8601"],"backgroundTag":"invalid-date-format","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}