HKUDS/Vibe-Trading · error · RegistryError
invalid {kind} {token!r}: must match {_ID_RE.pattern}
Error message
invalid {kind} {token!r}: must match {_ID_RE.pattern} What it means
_validate_id_token enforces that alpha/theme identifiers match _ID_RE (a restricted identifier pattern). Tokens with spaces, uppercase, special characters, or empty strings raise RegistryError.
Source
Thrown at agent/src/factors/registry.py:144
class SkipAlpha(Exception):
"""Raised when an alpha's preconditions (sector, columns) are not met."""
class RegistryError(Exception):
"""Raised on registry-level configuration errors."""
@dataclass(frozen=True, slots=True)
class _LoadError:
alpha_id: str
reason: str
def _validate_id_token(token: str, kind: str) -> None:
if not _ID_RE.fullmatch(token):
raise RegistryError(f"invalid {kind} {token!r}: must match {_ID_RE.pattern}")
def load_alpha_meta_from_py(path: Path) -> AlphaMeta:
"""AST-extract the ``__alpha_meta__`` dict literal from a zoo module.
No import is performed — purely static parsing. Raises ``RegistryError`` on
malformed metadata.
"""
size = path.stat().st_size
if size > _MAX_PY_BYTES:
raise RegistryError(f"{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap")
source = path.read_text(encoding="utf-8")
tree = ast.parse(source, filename=str(path))
meta_node: ast.expr | None = None
for stmt in tree.body:
if not isinstance(stmt, ast.Assign):View on GitHub (pinned to 80ffdda44c)
Solutions
- Rename the id to match _ID_RE (typically lowercase snake_case/kebab-case alphanumerics)
- Generate ids programmatically: re.sub(r'[^a-z0-9_-]', '', name.lower())
- Check the pattern printed in the error message and conform to it
Example fix
# before
__alpha_meta__ = {'alpha_id': 'Momentum Fast!', ...}
# after
__alpha_meta__ = {'alpha_id': 'momentum_fast', ...} Defensive patterns
Strategy: validation
Validate before calling
import re
_ID_RE = re.compile(r'[a-z0-9][a-z0-9_-]*') # mirror library pattern
assert _ID_RE.fullmatch(alpha_id), f'bad id: {alpha_id!r}' Type guard
def is_valid_id(token: str) -> bool:
return bool(_ID_RE.fullmatch(token)) Try / catch
try:
registry.register(path)
except RegistryError as e:
if 'must match' in str(e): fix_id_and_retry(path) Prevention
- Generate ids: re.sub(r'[^a-z0-9_-]+', '_', name.lower()).strip('_')
- Never hand-type display names as ids
When it happens
Trigger: Registering an alpha with id like 'My Alpha!', 'alpha#1', or '' in __alpha_meta__, or a theme token failing the same regex during scan/register.
Common situations: Auto-generating ids from filenames or display names with spaces/uppercase, hand-written metadata with friendly-looking names, or copy-pasted ids from another system with different id rules.
Related errors
- unknown panel column: {column}
- {path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap
- {path.name}: __alpha_meta__ assignment not found
- {path.name}: __alpha_meta__ not a literal: {exc}
- {path.name}: __alpha_meta__ must be dict, got {type(raw).__n
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/cc3655b155c60e32.
Report an issue: GitHub.