xai-org/x-algorithm · error · ValueError
Invalid argument , not a key=value replacement and no…
Error message
Invalid argument {arg!r}, not a key=value replacement and no matching preset found What it means
xai_configlib's replace_presets expands CLI arguments before applying them to a config. Each argument must either contain '=' (a direct key=value replacement) or match a key in the presets dict. Otherwise this ValueError is raised, listing the offending argument.
Solutions
- Fix the typo so the argument matches a preset name or is 'key=value'
- Print/inspect the presets dict passed in to see valid names
- If the argument should be a direct override, add '=' (e.g. 'lr=3e-4')
- If it's a new option, register it in PRESETS
Example fix
# before replace_cli_subs(cfg, ["leraning_rate"]) # after replace_cli_subs(cfg, ["lr=3e-4"]) # or a valid preset name
Defensive patterns
Strategy: validation
Validate before calling
def valid_args(args, presets):
bad = [a for a in args if "=" not in a and a not in presets]
assert not bad, f"Unknown preset args: {bad}; valid: {sorted(presets)}" Prevention
- Validate args against the presets dict before calling replace_cli_subs
- Log the available preset names in CLI help text
When it happens
Trigger: Calling replace_cli_subs (or a CLI wrapper) with an argument like 'foo' that has no '=' and no entry in the PRESETS mapping passed to replace_presets; typically a typo'd preset name or a flag-style argument ('--lr') passed where only kvs/preset names are accepted.
Common situations: Typos in preset names on the command line, presets renamed between config library versions, passing bare flags that the config layer does not support, or an empty/stale PRESETS dict.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Invalid config option
- Unused KV pairs
- Config module has no key . Available keys
- enable_candidate_tower_linear_proj and feature_prep_enabled…
- Expected bool [True, true, False, false], got
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/efb260dcf0e438c6.
Report an issue: GitHub.
Appendix: source
Thrown at phoenix/python/common/xai-configlib/src/xai_configlib/__init__.py:333
for kv in kvs:
k, v = parse_kv(kv)
key_path = tuple(k.split("."))
used = []
new_config = replace_recursive(new_config, (), key_path, v, used)
kv_used[k] = [".".join(x) for x in used]
return new_config, kv_used
def replace_presets(args: list[str], presets: dict[str, list[str]]) -> list[str]:
kvs = []
for arg in args:
if "=" in arg:
kvs.append(arg)
else:
preset = presets.get(arg)
if not preset:
raise ValueError(
f"Invalid argument {arg!r}, not a key=value replacement and no matching preset found"
)
kvs += preset
return kvs
def replace_recursive(
dcls: Any,
current_path: tuple[str, ...],
key_path: tuple[str, ...],
value: str,
used: list[tuple[str, ...]],
) -> Any:
new_dcls = dcls
ty_hints = resolve_type_hints(dcls)
for dataclass_field in dataclasses.fields(dcls):
name = dataclass_field.name
if not hasattr(dcls, name):View on GitHub (pinned to 24c60942c5)