HKUDS/Vibe-Trading · error · RegistryError
{path.name}: __alpha_meta__ must be dict, got {type(raw).__n
Error message
{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__} What it means
If __alpha_meta__ literal_evals successfully but is not a dict (e.g. a list, tuple, or string), RegistryError reports the actual type. AlphaMeta is a strict frozen pydantic model, so it must be constructed from a dict.
Source
Thrown at agent/src/factors/registry.py:178
meta_node: ast.expr | None = None
for stmt in tree.body:
if not isinstance(stmt, ast.Assign):
continue
targets = [t for t in stmt.targets if isinstance(t, ast.Name)]
if any(t.id == "__alpha_meta__" for t in targets):
meta_node = stmt.value
break
if meta_node is None:
raise RegistryError(f"{path.name}: __alpha_meta__ assignment not found")
try:
raw = ast.literal_eval(meta_node)
except (ValueError, SyntaxError) as exc:
raise RegistryError(f"{path.name}: __alpha_meta__ not a literal: {exc}") from exc
if not isinstance(raw, dict):
raise RegistryError(f"{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__}")
try:
return AlphaMeta(**raw)
except ValidationError as exc:
raise RegistryError(f"{path.name}: AlphaMeta validation failed: {exc}") from exc
def _safe_yaml_load(path: Path) -> Any:
"""yaml.safe_load with hard 5 MB size cap (defence in depth)."""
import yaml # local import keeps registry import-light
size = path.stat().st_size
if size > _MAX_YAML_BYTES:
raise RegistryError(f"{path.name}: {size}B exceeds {_MAX_YAML_BYTES}B YAML cap")
text = path.read_text(encoding="utf-8")
return yaml.safe_load(text)
View on GitHub (pinned to 80ffdda44c)
Solutions
- Rewrite __alpha_meta__ as a dict literal {key: value}
- Check the error message for the actual type found
Example fix
# before
__alpha_meta__ = [('alpha_id', 'x')]
# after
__alpha_meta__ = {'alpha_id': 'x'} Defensive patterns
Strategy: validation
Validate before calling
raw = ast.literal_eval(meta_expr)
assert isinstance(raw, dict), f'__alpha_meta__ must be dict, got {type(raw).__name__}' Type guard
def is_dict_meta(raw: object) -> bool:
return isinstance(raw, dict) Prevention
- Use a linter/template enforcing dict-literal meta
- Reject list-of-pairs style during code review
When it happens
Trigger: __alpha_meta__ = ['alpha_id', 'x'] or any literal that evaluates to a non-dict object.
Common situations: Typos like wrapping keys/values in a list, defining meta as a list of tuples (intending dict(...)), or a stale format from an older schema.
Related errors
- metadata must be a mapping, got {type(self.metadata).__name_
- kind must be a string, got {type(value).__name__}
- amount must be numeric, got {self.amount!r}
- CashFlowSeries members must be CashFlow, got {type(item).__n
- rate must be numeric, got {self.rate!r}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/bbe5197f40f19e2d.
Report an issue: GitHub.