HKUDS/Vibe-Trading · error · RegistryError

{path.name}: AlphaMeta validation failed: {exc}

Error message

{path.name}: AlphaMeta validation failed: {exc}

What it means

The dict extracted from __alpha_meta__ is validated against the AlphaMeta pydantic model, which is strict (extra='forbid', frozen). Unknown fields, missing required fields, or wrong value types cause ValidationError wrapped in RegistryError.

Source

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

        if any(t.id == "__alpha_meta__" for t in targets):
            meta_node = stmt.value
            break

    if meta_node is None:
        raise RegistryError(f"{path.name}: __alpha_meta__ assignment not found")

    try:
        raw = ast.literal_eval(meta_node)
    except (ValueError, SyntaxError) as exc:
        raise RegistryError(f"{path.name}: __alpha_meta__ not a literal: {exc}") from exc

    if not isinstance(raw, dict):
        raise RegistryError(f"{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__}")

    try:
        return AlphaMeta(**raw)
    except ValidationError as exc:
        raise RegistryError(f"{path.name}: AlphaMeta validation failed: {exc}") from exc


def _safe_yaml_load(path: Path) -> Any:
    """yaml.safe_load with hard 5 MB size cap (defence in depth)."""
    import yaml  # local import keeps registry import-light

    size = path.stat().st_size
    if size > _MAX_YAML_BYTES:
        raise RegistryError(f"{path.name}: {size}B exceeds {_MAX_YAML_BYTES}B YAML cap")
    text = path.read_text(encoding="utf-8")
    return yaml.safe_load(text)


def _zoo_dir_default() -> Path:
    return Path(__file__).parent / "zoo"


class Registry:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Read the wrapped pydantic error to see the exact field problem
  2. Remove unknown keys and add missing required keys per the current AlphaMeta schema
  3. Regenerate alphas with the current template after library upgrades

Example fix

# before
__alpha_meta__ = {'alpha_id': 'x', 'author': 'me'}  # 'author' unknown
# after
__alpha_meta__ = {'alpha_id': 'x'}  # only schema fields
Defensive patterns

Strategy: try-catch

Validate before calling

from factors.registry import AlphaMeta
AlphaMeta(**raw)  # dry-run validation before register

Try / catch

try:
    AlphaMeta(**raw)
except ValidationError as e:
    print(f'fix fields: {e.errors()}')  # each item shows loc/msg

Prevention

When it happens

Trigger: Including a field not in the AlphaMeta schema, omitting a required field, or supplying a wrong type (e.g. window: 'five' instead of int).

Common situations: Schema evolution after upgrading the library (renamed fields), hand-copied metadata from another repo with extra keys, or forgetting newly-required fields in generated alphas.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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