{"record":{"id":"970f06ad7f96377e","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-cannot-stat-source-exc","errorCode":null,"errorMessage":"{alpha_id}: cannot stat source: {exc}","messagePattern":"(.+?): cannot stat source: (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":302,"sourceCode":"            raise KeyError(f\"alpha_id {alpha_id!r} not in registry\")\n        return self._alphas[alpha_id]\n\n    def get_source(self, alpha_id: str) -> str:\n        \"\"\"Return the raw .py source of a registered alpha (size-capped).\n\n        Raises:\n            KeyError: alpha_id unknown.\n            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","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L284-L320","documentation":"get_source stats the recorded .py file before reading and wraps any OSError (file deleted, permission denied, path on an unmounted drive) into a RegistryError. The original OSError is chained as __cause__. It means the path was recorded but is no longer accessible at stat time.","triggerScenarios":"get_source(alpha_id) after the source file was deleted, renamed, or made unreadable (permissions/ownership), or when the recorded path points to a network mount that is down.","commonSituations":"Cleanup jobs or re-cloning the repo after registry load; container environments where files are copied between registration and read; restrictive file permissions.","solutions":["Verify the file exists at the path shown in the message","Restore or re-scan the registry so paths point at existing files","Fix permissions/ownership on the source tree"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\np = registry._py_paths.get(alpha_id)\nif p and not os.path.exists(p):\n    raise FileNotFoundError(p)","typeGuard":null,"tryCatchPattern":"try:\n    src = registry.get_source(aid)\nexcept RegistryError as e:\n    if 'cannot stat' in str(e):\n        registry.reload(); src = registry.get_source(aid)\n    else: raise","preventionTips":["Don't delete/move zoo files while registry is live","Re-scan registry after repo changes"],"tags":["filesystem","registry","io-error"],"backgroundTag":"file-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}