{"record":{"id":"6df815d2992c77b8","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-cannot-read-source-exc","errorCode":null,"errorMessage":"{alpha_id}: cannot read source: {exc}","messagePattern":"(.+?): cannot read source: (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":310,"sourceCode":"            RegistryError: source file exceeds ``_MAX_PY_BYTES`` or cannot be read.\n        \"\"\"\n        if alpha_id not in self._alphas:\n            raise KeyError(f\"alpha_id {alpha_id!r} not in registry\")\n        py_path = self._py_paths.get(alpha_id)\n        if py_path is None:\n            raise RegistryError(f\"{alpha_id}: no source path recorded\")\n        try:\n            size = py_path.stat().st_size\n        except OSError as exc:\n            raise RegistryError(f\"{alpha_id}: cannot stat source: {exc}\") from exc\n        if size > _MAX_PY_BYTES:\n            raise RegistryError(\n                f\"{alpha_id}: source {size}B exceeds {_MAX_PY_BYTES}B cap\"\n            )\n        try:\n            return py_path.read_text(encoding=\"utf-8\")\n        except OSError as exc:\n            raise RegistryError(f\"{alpha_id}: cannot read source: {exc}\") from exc\n\n    def health(self) -> dict[str, Any]:\n        return {\n            \"loaded\": len(self._alphas),\n            \"failed\": len(self._load_errors),\n            \"errors\": [\n                {\"alpha_id\": e.alpha_id, \"reason\": e.reason} for e in self._load_errors\n            ],\n        }\n\n    def compute(self, alpha_id: str, panel: dict[str, pd.DataFrame]) -> pd.DataFrame:\n        \"\"\"Lazy-import the alpha module and run its ``compute(panel)``.\n\n        Raises:\n            KeyError: alpha_id unknown.\n            SkipAlpha: required column / sector tag absent in panel.\n            RegistryError: import/compute failed or output failed sanity checks.\n        \"\"\"","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L292-L328","documentation":"The final read of the source file failed with an OSError after the stat succeeded; get_source wraps it as RegistryError with the underlying error chained. Typical causes are transient permission/lock issues or the file disappearing between stat and read (TOCTOU).","triggerScenarios":"get_source(alpha_id) where the file passes the size check but read_text then fails — antivirus locks, concurrent deletion, encoding-adjacent OS errors.","commonSituations":"Windows file locking; files removed by another process mid-call; container layer permission quirks.","solutions":["Retry once — these are often transient","Check for concurrent processes deleting/rewriting the zoo files","Confirm read permissions on the file"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        return registry.get_source(aid)\n    except RegistryError as e:\n        if 'cannot read' not in str(e) or attempt: raise","preventionTips":["Avoid concurrent deletion of zoo files","Close file handles / disable scanners on the zoo dir"],"tags":["filesystem","race-condition","io-error"],"backgroundTag":"file-read-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}