{"record":{"id":"07b90b01c3bc8a4a","repo":"HKUDS/Vibe-Trading","slug":"path-name-size-b-exceeds-max-py-bytes-b-cap","errorCode":null,"errorMessage":"{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap","messagePattern":"(.+?): (.+?)B exceeds (.+?)B cap","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":155,"sourceCode":"class _LoadError:\n    alpha_id: str\n    reason: str\n\n\ndef _validate_id_token(token: str, kind: str) -> None:\n    if not _ID_RE.fullmatch(token):\n        raise RegistryError(f\"invalid {kind} {token!r}: must match {_ID_RE.pattern}\")\n\n\ndef load_alpha_meta_from_py(path: Path) -> AlphaMeta:\n    \"\"\"AST-extract the ``__alpha_meta__`` dict literal from a zoo module.\n\n    No import is performed — purely static parsing. Raises ``RegistryError`` on\n    malformed metadata.\n    \"\"\"\n    size = path.stat().st_size\n    if size > _MAX_PY_BYTES:\n        raise RegistryError(f\"{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap\")\n\n    source = path.read_text(encoding=\"utf-8\")\n    tree = ast.parse(source, filename=str(path))\n\n    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)","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L137-L173","documentation":"load_alpha_meta_from_py statically AST-parses zoo modules and refuses any .py file larger than _MAX_PY_BYTES as a defence against bloated or malicious modules. Exceeding the cap raises RegistryError before reading/parsing.","triggerScenarios":"Registering a zoo module whose file size exceeds _MAX_PY_BYTES (oversized generated alphas, embedded data blobs, or accidentally concatenated files).","commonSituations":"Embedding large lookup tables or payloads inside an alpha module, code generation tools appending duplicate code until the file grows past the cap, or committing generated artifacts into the zoo directory.","solutions":["Move large data out of the module into a data file the alpha loads separately","Split the module or remove embedded blobs/dead code","If genuinely needed and you accept the risk, raise _MAX_PY_BYTES in your fork"],"exampleFix":"# before\n# alpha_big.py contains a 2MB inline price table\n# after\n# alpha loads table from data/prices.parq at runtime; module stays small","handlingStrategy":"validation","validationCode":"from factors.registry import _MAX_PY_BYTES\nassert path.stat().st_size <= _MAX_PY_BYTES, f'{path} too large'","typeGuard":null,"tryCatchPattern":"try:\n    load_alpha_meta_from_py(path)\nexcept RegistryError as e:\n    if 'exceeds' in str(e): log.error('move embedded data out of module')","preventionTips":["Keep data blobs out of zoo modules; load from data files at runtime","Monitor zoo file sizes in CI"],"tags":["registry","file-size-cap","static-analysis"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}