{"record":{"id":"187653b132b54304","repo":"HKUDS/Vibe-Trading","slug":"unknown-theme-theme-r-expected-one-of-sorted","errorCode":null,"errorMessage":"unknown theme {theme!r}; expected one of {sorted(_VALID_THEMES)}","messagePattern":"unknown theme (.+?); expected one of (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"agent/src/api/alpha_routes.py","lineNumber":397,"sourceCode":"    # -----------------------------------------------------------------------\n    # GET /alpha/list\n    # -----------------------------------------------------------------------\n\n    @app.get(\"/alpha/list\", dependencies=[Depends(require_auth)])\n    async def list_alphas(\n        zoo: str | None = Query(None, max_length=64),\n        theme: str | None = Query(None, max_length=64),\n        universe: str | None = Query(None, max_length=64),\n        limit: int = Query(100, ge=1, le=1000),\n    ) -> dict[str, Any]:\n        \"\"\"List alphas, optionally filtered by zoo / theme / universe.\"\"\"\n        if zoo is not None and zoo not in _VALID_ZOOS:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"unknown zoo {zoo!r}; expected one of {sorted(_VALID_ZOOS)}\",\n            )\n        if theme is not None and theme not in _VALID_THEMES:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"unknown theme {theme!r}; expected one of {sorted(_VALID_THEMES)}\",\n            )\n        if universe is not None:\n            _ALIAS = {\"csi300\": \"equity_cn\", \"sp500\": \"equity_us\", \"btc-usdt\": \"crypto\"}\n            universe = _ALIAS.get(universe, universe)\n        if universe is not None and universe not in _VALID_UNIVERSES:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"unknown universe {universe!r}; expected one of {sorted(_VALID_UNIVERSES)}\",\n            )\n\n        from src.factors.registry import get_default_registry\n\n        registry = get_default_registry()\n        try:\n            ids = registry.list(zoo=zoo, theme=theme, universe=universe)\n        except Exception as exc:  # noqa: BLE001","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/alpha_routes.py#L379-L415","documentation":"profile_by_id resolves a trading connector profile by id (falling back to the selected profile from config when profile_id is empty). After normalizing to stripped lowercase, if no profile in list_profiles() matches, it raises ValueError 'unknown trading connector profile'.","triggerScenarios":"Passing --profile <id> that isn't in the discovered profile list (CLI cmd_connector_use, verify_connector_endpoint, parse_settings, or service-level execute); having a selected profile id in config whose plugin was removed; case/whitespace variants are handled, so it must be a genuinely unknown id.","commonSituations":"Typos in profile ids, referencing a profile from another machine, uninstalling a local connector while it's still selected in config, or schema changes renaming profile ids (e.g. '-live-readonly' suffix added/changed).","solutions":["List available profiles (list_profiles) and use an exact id from the output","If the selected profile is stale, re-select a valid profile (cmd_connector_use) or clear/fix the config file","Reinstall the local connector whose profile disappeared, or update the id to the current naming scheme"],"exampleFix":"# before\nprofile = profile_by_id(\"acme-live\")  # ValueError: unknown\n\n# after\nfrom src.trading.profiles import list_profiles\nvalid = {p.id for p in list_profiles()}\nprofile = profile_by_id(\"acme-live-readonly\")  # exact id from list_profiles\nassert profile.id in valid","handlingStrategy":"validation","validationCode":"from src.trading.profiles import list_profiles\n\ndef profile_exists(profile_id: str) -> bool:\n    ids = {p.id for p in list_profiles()}\n    return (profile_id or \"\").strip().lower() in ids\n\ndef safe_profile_id(profile_id: str) -> str | None:\n    ids = {p.id for p in list_profiles()}\n    target = (profile_id or \"\").strip().lower()\n    return target if target in ids else None","typeGuard":null,"tryCatchPattern":"try:\n    profile = profile_by_id(profile_id)\nexcept ValueError as e:\n    if \"unknown trading connector profile\" in str(e):\n        available = [p.id for p in list_profiles()]\n        raise ValueError(f\"unknown profile {profile_id!r}; available: {available}\") from e\n    raise","preventionTips":["Always source profile ids from list_profiles output, never hardcode","After uninstalling a connector, re-select a valid profile immediately","Validate the configured selected profile on startup"],"tags":["profiles","configuration","unknown-id","trading"],"backgroundTag":"invalid-configuration-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}