xai-org/x-algorithm · error · ValueError
No task generator registered for type {cfg.type!r}. Register
Error message
No task generator registered for type {cfg.type!r}. Registered: {sorted(_REGISTRY)} What it means
build(cfg) resolves a TaskGeneratorConfig to a registered class via cfg.type. If no class was registered under that type string, there is no way to construct the generator, so it raises ValueError listing all registered types to aid diagnosis.
Source
Thrown at grox/core/generators/registry.py:29
)
if not cls.TASK_GENERATOR_TYPE:
raise ValueError(
f"{cls.__name__} must set TASK_GENERATOR_TYPE to be registered"
)
key = cls.TASK_GENERATOR_TYPE
existing = _REGISTRY.get(key)
if existing is not None and existing is not cls:
raise ValueError(
f"Duplicate generator registration for {key!r}: {existing.__name__} vs {cls.__name__}"
)
_REGISTRY[key] = cls
return cls
def build(cfg: TaskGeneratorConfig) -> TaskGenerator:
cls = _REGISTRY.get(cfg.type)
if cls is None:
raise ValueError(
f"No task generator registered for type {cfg.type!r}. Registered: {sorted(_REGISTRY)}"
)
return cls.from_config(cfg)
def registered_types() -> set[str]:
return set(_REGISTRY)
View on GitHub (pinned to 24c60942c5)
Solutions
- Import the module that defines (and decorates) the generator before calling build so registration happens.
- Fix the type string in the config to exactly match TASK_GENERATOR_TYPE (the error message lists valid values).
- Ensure the value's case/whitespace matches — no stripping is done.
- If the generator lives in a plugin package, verify the package is installed and its import side effects run.
Example fix
# before cfg = TaskGeneratorConfig(type="task_gen") gen = build(cfg) # registry has "task_generator" # after import mypkg.generators.my_gen # triggers @register_task_generator cfg = TaskGeneratorConfig(type="my_gen") gen = build(cfg)
Defensive patterns
Strategy: validation
Validate before calling
from grox.core.generators.registry import registered_types
if cfg.type not in registered_types():
raise ValueError(f"unknown generator {cfg.type}; known: {registered_types()}")
import mypkg.generators # ensure registrations ran Type guard
def config_type_is_registered(cfg) -> bool:
from grox.core.generators.registry import registered_types
return cfg.type in registered_types() Try / catch
try:
gen = build(cfg)
except ValueError as e:
if "No task generator registered" in str(e):
import mypkg.generators # late import to register
gen = build(cfg)
else:
raise Prevention
- Import all generator modules once at app startup before building configs.
- Validate config type strings against registered_types() at config load time.
- Add a smoke test that every config-referenced type is registered.
When it happens
Trigger: Calling registry.build with a TaskGeneratorConfig whose type string doesn't match any registered TASK_GENERATOR_TYPE; typo in config; generator module never imported (so its @register_task_generator never ran).
Common situations: Config file references a generator from a module that isn't imported/installed; renaming a generator's type without updating configs; typos or casing mismatches in the type string; plugin module not loaded in the entry point.
Related errors
- {cls.__name__} must set TASK_GENERATOR_TYPE to be registered
- Duplicate generator registration for {key!r}: {existing.__na
- head registry hash {head_cfg.get('head_registry_hash')} != {
- register_task_generator expects a TaskGenerator subclass, go
- No generators provided
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/b1f775a4f3ac898f.
Report an issue: GitHub.