HKUDS/Vibe-Trading · error · RegistryError

{alpha_id}: cannot read source: {exc}

Error message

{alpha_id}: cannot read source: {exc}

What it means

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).

Source

Thrown at agent/src/factors/registry.py:310

            RegistryError: source file exceeds ``_MAX_PY_BYTES`` or cannot be read.
        """
        if alpha_id not in self._alphas:
            raise KeyError(f"alpha_id {alpha_id!r} not in registry")
        py_path = self._py_paths.get(alpha_id)
        if py_path is None:
            raise RegistryError(f"{alpha_id}: no source path recorded")
        try:
            size = py_path.stat().st_size
        except OSError as exc:
            raise RegistryError(f"{alpha_id}: cannot stat source: {exc}") from exc
        if size > _MAX_PY_BYTES:
            raise RegistryError(
                f"{alpha_id}: source {size}B exceeds {_MAX_PY_BYTES}B cap"
            )
        try:
            return py_path.read_text(encoding="utf-8")
        except OSError as exc:
            raise RegistryError(f"{alpha_id}: cannot read source: {exc}") from exc

    def health(self) -> dict[str, Any]:
        return {
            "loaded": len(self._alphas),
            "failed": len(self._load_errors),
            "errors": [
                {"alpha_id": e.alpha_id, "reason": e.reason} for e in self._load_errors
            ],
        }

    def compute(self, alpha_id: str, panel: dict[str, pd.DataFrame]) -> pd.DataFrame:
        """Lazy-import the alpha module and run its ``compute(panel)``.

        Raises:
            KeyError: alpha_id unknown.
            SkipAlpha: required column / sector tag absent in panel.
            RegistryError: import/compute failed or output failed sanity checks.
        """

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Retry once — these are often transient
  2. Check for concurrent processes deleting/rewriting the zoo files
  3. Confirm read permissions on the file
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(2):
    try:
        return registry.get_source(aid)
    except RegistryError as e:
        if 'cannot read' not in str(e) or attempt: raise

Prevention

When it happens

Trigger: get_source(alpha_id) where the file passes the size check but read_text then fails — antivirus locks, concurrent deletion, encoding-adjacent OS errors.

Common situations: Windows file locking; files removed by another process mid-call; container layer permission quirks.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/6df815d2992c77b8. Report an issue: GitHub.