xai-org/x-algorithm · error · ValueError
Invalid config option {kv!r}, expected format 'key=value'
Error message
Invalid config option {kv!r}, expected format 'key=value' What it means
parse_kv splits each override string on the first '='; a string with no '=' cannot produce a (key, value) pair and raises this ValueError.
Source
Thrown at phoenix/python/common/xai-configlib/src/xai_configlib/__init__.py:547
def _coerce_enums_from_hint(vtype: Any, value: Any) -> Any:
inner = _unwrap_optional(vtype)
if isinstance(inner, enum.EnumMeta):
return _coerce_enum_value(inner, value)
if is_list(inner) and isinstance(value, list):
elem_args = get_args(inner)
if len(elem_args) == 1 and isinstance(elem_args[0], enum.EnumMeta):
enum_cls = elem_args[0]
if value and all(isinstance(x, enum_cls) for x in value):
return value
return [_coerce_enum_value(enum_cls, x) for x in value]
return value
def parse_kv(kv: str) -> tuple[str, str]:
parts = kv.split("=", 1)
if len(parts) < 2:
raise ValueError(f"Invalid config option {kv!r}, expected format 'key=value'")
return tuple(parts)
def get_module(mod_path: str) -> ModuleType:
try:
return importlib.import_module(mod_path)
except ModuleNotFoundError as e:
raise type(e)(
f"No module found {mod_path!r}, "
f"or {mod_path!r} has another import issue: {traceback.format_exc()}"
) from e
def get_configs_from_mod(
mod: ModuleType,
) -> dict[str, Config] | None:
if "CONFIGS" not in dir(mod):
return NoneView on GitHub (pinned to 24c60942c5)
Solutions
- Convert flags to explicit key=value ('verbose=True')
- Filter empty strings out of the args list before calling
- Check for unexpanded shell variables ("$VAR" empty) producing malformed args
Example fix
# before
parse_kv("verbose")
# after
parse_kv("verbose=True") Defensive patterns
Strategy: validation
Validate before calling
kvs = [kv for kv in kvs if kv.strip()]
assert all("=" in kv for kv in kvs), f"Malformed overrides: {[kv for kv in kvs if '=' not in kv]}" Type guard
def is_kv(s: str) -> bool:
return isinstance(s, str) and "=" in s Prevention
- Quote overrides in shell
- Filter empty args from variable expansions
When it happens
Trigger: Passing a bare token like 'verbose' or '--flag' into parse_kv via replace_cli_subs; also an empty string argument.
Common situations: Attempting to use boolean-flag style CLI arguments with a key=value config system, or leftover shell glob expansions producing '='-less tokens.
Related errors
- Invalid argument {arg!r}, not a key=value replacement and no
- Unused KV pairs: {k}
- Non-optional parameter %s must be declared before optional p
- Duplicated argument name %s
- 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/118c3cadc9149c71.
Report an issue: GitHub.