HKUDS/Vibe-Trading · error · HTTPException
unknown theme {theme!r}; expected one of {sorted(_VALID_THEM
Error message
unknown theme {theme!r}; expected one of {sorted(_VALID_THEMES)} What it means
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'.
Source
Thrown at agent/src/api/alpha_routes.py:397
# -----------------------------------------------------------------------
# GET /alpha/list
# -----------------------------------------------------------------------
@app.get("/alpha/list", dependencies=[Depends(require_auth)])
async def list_alphas(
zoo: str | None = Query(None, max_length=64),
theme: str | None = Query(None, max_length=64),
universe: str | None = Query(None, max_length=64),
limit: int = Query(100, ge=1, le=1000),
) -> dict[str, Any]:
"""List alphas, optionally filtered by zoo / theme / universe."""
if zoo is not None and zoo not in _VALID_ZOOS:
raise HTTPException(
status_code=400,
detail=f"unknown zoo {zoo!r}; expected one of {sorted(_VALID_ZOOS)}",
)
if theme is not None and theme not in _VALID_THEMES:
raise HTTPException(
status_code=400,
detail=f"unknown theme {theme!r}; expected one of {sorted(_VALID_THEMES)}",
)
if universe is not None:
_ALIAS = {"csi300": "equity_cn", "sp500": "equity_us", "btc-usdt": "crypto"}
universe = _ALIAS.get(universe, universe)
if universe is not None and universe not in _VALID_UNIVERSES:
raise HTTPException(
status_code=400,
detail=f"unknown universe {universe!r}; expected one of {sorted(_VALID_UNIVERSES)}",
)
from src.factors.registry import get_default_registry
registry = get_default_registry()
try:
ids = registry.list(zoo=zoo, theme=theme, universe=universe)
except Exception as exc: # noqa: BLE001View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before
profile = profile_by_id("acme-live") # ValueError: unknown
# after
from src.trading.profiles import list_profiles
valid = {p.id for p in list_profiles()}
profile = profile_by_id("acme-live-readonly") # exact id from list_profiles
assert profile.id in valid Defensive patterns
Strategy: validation
Validate before calling
from src.trading.profiles import list_profiles
def profile_exists(profile_id: str) -> bool:
ids = {p.id for p in list_profiles()}
return (profile_id or "").strip().lower() in ids
def safe_profile_id(profile_id: str) -> str | None:
ids = {p.id for p in list_profiles()}
target = (profile_id or "").strip().lower()
return target if target in ids else None Try / catch
try:
profile = profile_by_id(profile_id)
except ValueError as e:
if "unknown trading connector profile" in str(e):
available = [p.id for p in list_profiles()]
raise ValueError(f"unknown profile {profile_id!r}; available: {available}") from e
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
Related errors
- connection profile is not eligible for read-only portfolios:
- unknown zoo {v!r}; expected one of {sorted(_VALID_ZOOS)}
- unknown universe {v!r}; expected one of {sorted(_BENCH_UNIVE
- invalid alpha_id {aid!r}
- need at least 2 distinct alpha_ids to compare
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/187653b132b54304.
Report an issue: GitHub.