{"record":{"id":"6d5c1d9ddcae41b9","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-compute-raised-exc","errorCode":null,"errorMessage":"{alpha_id}: compute() raised: {exc}","messagePattern":"(.+?): compute\\(\\) raised: (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":353,"sourceCode":"        missing_extra = [c for c in meta.get(\"extras_required\", []) if c not in panel]\n        if missing_extra:\n            raise SkipAlpha(f\"{alpha_id}: panel missing extras {missing_extra}\")\n        if meta.get(\"requires_sector\") and \"sector\" not in panel:\n            raise SkipAlpha(f\"{alpha_id}: panel missing sector tag\")\n\n        try:\n            module = self._load_module(alpha)\n        except Exception as exc:  # noqa: BLE001 — isolate import failure\n            raise RegistryError(f\"{alpha_id}: import failed: {exc}\") from exc\n\n        compute_fn = getattr(module, \"compute\", None)\n        if compute_fn is None:\n            raise RegistryError(f\"{alpha_id}: module has no compute() function\")\n\n        try:\n            result = compute_fn(panel)\n        except Exception as exc:  # noqa: BLE001 — isolate compute failure\n            raise RegistryError(f\"{alpha_id}: compute() raised: {exc}\") from exc\n\n        return self._validate_output(alpha_id, result, panel)\n\n    def _load_module(self, alpha: Alpha) -> ModuleType:\n        if not self._use_filesystem_loader:\n            return importlib.import_module(alpha.module_path)\n        py_file = self._py_paths[alpha.id]\n        cached = sys.modules.get(alpha.module_path)\n        if cached is not None and getattr(cached, \"__file__\", None) == str(py_file):\n            return cached\n        spec = importlib.util.spec_from_file_location(alpha.module_path, py_file)\n        if spec is None or spec.loader is None:\n            raise RegistryError(f\"{alpha.id}: could not build import spec for {py_file}\")\n        module = importlib.util.module_from_spec(spec)\n        sys.modules[alpha.module_path] = module\n        try:\n            spec.loader.exec_module(module)\n        except Exception:","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L335-L371","documentation":"The alpha's compute() itself raised an exception; the registry catches it (isolating factor failures) and re-raises as RegistryError with the original chained. The message embeds the inner exception text; __cause__ preserves the full traceback.","triggerScenarios":"compute(alpha_id, panel) where the factor code hits KeyError on an unexpected panel layout, pandas errors (misaligned indexes, dtype issues), division producing object dtype, etc.","commonSituations":"Panel index/columns not aligned with expectations; NaN-only inputs triggering pandas edge cases; dtype problems (strings in numeric columns); lookalike data bugs in the factor formula.","solutions":["Debug with exc.__cause__ traceback and reproduce by calling module.compute(panel) directly","Fix panel alignment/dtypes or the factor formula accordingly","Skip failing alphas in batch runs (catch RegistryError per alpha)"],"exampleFix":"# before\nout = registry.compute(alpha_id, panel)  # compute() raised\n# after\nimport traceback\ntry:\n    out = registry.compute(alpha_id, panel)\nexcept RegistryError as e:\n    traceback.print_exception(e.__cause__)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    out = registry.compute(aid, panel)\nexcept RegistryError as e:\n    if 'compute() raised' in str(e):\n        log(aid, repr(e.__cause__)); continue\n    raise","preventionTips":["Test factors on a known-good golden panel","Catch RegistryError per alpha in batch loops to isolate failures"],"tags":["computation","pandas","registry"],"backgroundTag":"callback-raised-exception","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}