{"record":{"id":"bbe5197f40f19e2d","repo":"HKUDS/Vibe-Trading","slug":"path-name-alpha-meta-must-be-dict-got-typ","errorCode":null,"errorMessage":"{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__}","messagePattern":"(.+?): __alpha_meta__ must be dict, got (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":178,"sourceCode":"    meta_node: ast.expr | None = None\n    for stmt in tree.body:\n        if not isinstance(stmt, ast.Assign):\n            continue\n        targets = [t for t in stmt.targets if isinstance(t, ast.Name)]\n        if any(t.id == \"__alpha_meta__\" for t in targets):\n            meta_node = stmt.value\n            break\n\n    if meta_node is None:\n        raise RegistryError(f\"{path.name}: __alpha_meta__ assignment not found\")\n\n    try:\n        raw = ast.literal_eval(meta_node)\n    except (ValueError, SyntaxError) as exc:\n        raise RegistryError(f\"{path.name}: __alpha_meta__ not a literal: {exc}\") from exc\n\n    if not isinstance(raw, dict):\n        raise RegistryError(f\"{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__}\")\n\n    try:\n        return AlphaMeta(**raw)\n    except ValidationError as exc:\n        raise RegistryError(f\"{path.name}: AlphaMeta validation failed: {exc}\") from exc\n\n\ndef _safe_yaml_load(path: Path) -> Any:\n    \"\"\"yaml.safe_load with hard 5 MB size cap (defence in depth).\"\"\"\n    import yaml  # local import keeps registry import-light\n\n    size = path.stat().st_size\n    if size > _MAX_YAML_BYTES:\n        raise RegistryError(f\"{path.name}: {size}B exceeds {_MAX_YAML_BYTES}B YAML cap\")\n    text = path.read_text(encoding=\"utf-8\")\n    return yaml.safe_load(text)\n\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L160-L196","documentation":"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.","triggerScenarios":"__alpha_meta__ = ['alpha_id', 'x'] or any literal that evaluates to a non-dict object.","commonSituations":"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.","solutions":["Rewrite __alpha_meta__ as a dict literal {key: value}","Check the error message for the actual type found"],"exampleFix":"# before\n__alpha_meta__ = [('alpha_id', 'x')]\n# after\n__alpha_meta__ = {'alpha_id': 'x'}","handlingStrategy":"validation","validationCode":"raw = ast.literal_eval(meta_expr)\nassert isinstance(raw, dict), f'__alpha_meta__ must be dict, got {type(raw).__name__}'","typeGuard":"def is_dict_meta(raw: object) -> bool:\n    return isinstance(raw, dict)","tryCatchPattern":null,"preventionTips":["Use a linter/template enforcing dict-literal meta","Reject list-of-pairs style during code review"],"tags":["registry","type-validation","metadata"],"backgroundTag":"metadata-type-mismatch","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}