{"record":{"id":"efb260dcf0e438c6","repo":"xai-org/x-algorithm","slug":"invalid-argument-arg-r-not-a-key-value-replacem","errorCode":null,"errorMessage":"Invalid argument {arg!r}, not a key=value replacement and no matching preset found","messagePattern":"Invalid argument (.+?), not a key=value replacement and no matching preset found","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/python/common/xai-configlib/src/xai_configlib/__init__.py","lineNumber":333,"sourceCode":"\n    for kv in kvs:\n        k, v = parse_kv(kv)\n        key_path = tuple(k.split(\".\"))\n        used = []\n        new_config = replace_recursive(new_config, (), key_path, v, used)\n        kv_used[k] = [\".\".join(x) for x in used]\n    return new_config, kv_used\n\n\ndef replace_presets(args: list[str], presets: dict[str, list[str]]) -> list[str]:\n    kvs = []\n    for arg in args:\n        if \"=\" in arg:\n            kvs.append(arg)\n        else:\n            preset = presets.get(arg)\n            if not preset:\n                raise ValueError(\n                    f\"Invalid argument {arg!r}, not a key=value replacement and no matching preset found\"\n                )\n            kvs += preset\n    return kvs\n\n\ndef replace_recursive(\n    dcls: Any,\n    current_path: tuple[str, ...],\n    key_path: tuple[str, ...],\n    value: str,\n    used: list[tuple[str, ...]],\n) -> Any:\n    new_dcls = dcls\n    ty_hints = resolve_type_hints(dcls)\n    for dataclass_field in dataclasses.fields(dcls):\n        name = dataclass_field.name\n        if not hasattr(dcls, name):","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/python/common/xai-configlib/src/xai_configlib/__init__.py#L315-L351","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nreplace_cli_subs(cfg, [\"leraning_rate\"])\n# after\nreplace_cli_subs(cfg, [\"lr=3e-4\"])  # or a valid preset name","handlingStrategy":"validation","validationCode":"def valid_args(args, presets):\n    bad = [a for a in args if \"=\" not in a and a not in presets]\n    assert not bad, f\"Unknown preset args: {bad}; valid: {sorted(presets)}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate args against the presets dict before calling replace_cli_subs","Log the available preset names in CLI help text"],"tags":["config","cli","validation","xai-configlib"],"backgroundTag":"invalid-cli-argument","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}