xai-org/x-algorithm · error · ValueError
Module {mod_name!r} does not have CONFIGS
Error message
Module {mod_name!r} does not have CONFIGS What it means
After successfully importing the target config module, get_named_config_from_module expects a module-level CONFIGS mapping. If get_configs_from_mod returns None (no CONFIGS attribute), this ValueError is raised.
Source
Thrown at phoenix/python/common/xai-configlib/src/xai_configlib/__init__.py:593
) -> Config:
parts = name.split(".", 1)
if len(parts) < 2:
raise ValueError(f"Invalid config {name!r}, expected format 'module.key'")
mod_name, ver = parts
try:
mod = get_module(f"{base_module_name}.{mod_name}")
except ModuleNotFoundError as e:
if on_failure_log_additional_info:
discovered_configs = get_all_configs_from_module(
base_module_name, ignore_loading_errors=True
)
available_configs = sorted(discovered_configs.configs.keys())
print(f"Available configs: {available_configs}")
raise e
configs = get_configs_from_mod(mod)
if configs is None:
raise ValueError(f"Module {mod_name!r} does not have CONFIGS")
if ver not in configs:
avail = ", ".join(configs.keys())
raise ValueError(f"Config module {mod_name!r} has no key {ver!r}. Available keys: {avail}")
return configs[ver]
class DiscoveredConfigsInModule(NamedTuple):
configs: dict[str, Config]
failing_modules: list[str]
def get_all_configs_from_module(
base_module_name: str,
ignore_loading_errors: bool = False,
) -> DiscoveredConfigsInModule:
mod = get_module(base_module_name)
if not hasattr(mod, "__path__"):View on GitHub (pinned to 24c60942c5)
Solutions
- Add a module-level CONFIGS: dict[str, Config] to the module
- Rename any legacy variable back to CONFIGS
- Point the name at a module that actually declares CONFIGS
Example fix
# before
# my_cfg.py
configs = {"v1": Config()}
# after
CONFIGS = {"v1": Config()} Defensive patterns
Strategy: validation
Validate before calling
import importlib
mod = importlib.import_module(f"{base}.{mod_name}")
assert hasattr(mod, "CONFIGS"), f"{mod_name} lacks CONFIGS" Type guard
def has_configs(mod) -> bool:
return hasattr(mod, "CONFIGS") and isinstance(getattr(mod, "CONFIGS"), dict) Prevention
- Lint config modules to require a CONFIGS dict
- Name the variable CONFIGS exactly
When it happens
Trigger: The module under the base package imports fine but defines no CONFIGS dict (e.g. it's a helper module, or CONFIGS was renamed to configs/_CONFIGS).
Common situations: Refactoring config modules and dropping the CONFIGS convention, or pointing the loader at a utility module rather than a config module.
Related errors
- Invalid config {name!r}, expected format 'module.key'
- Module '{base_module_name}' is not a package containing conf
- Invalid config {name!r}, expected format 'module.key' where
- Invalid argument {arg!r}, not a key=value replacement and no
- Expected bool [True, true, False, false], got {val!r}
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/8c80de3abba9bf94.
Report an issue: GitHub.