{"record":{"id":"e55b0bc94714b1f0","repo":"sgl-project/sglang","slug":"unknown-value-for-flag-name-available-list","errorCode":null,"errorMessage":"Unknown value for {flag}: {name}. Available: {list(mapping.keys())}","messagePattern":"Unknown value for (.+?): (.+?)\\. Available: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/debug_utils/comparator/preset.py","lineNumber":48,"sourceCode":"        return expanded\n\n    if \"--grouping-skip-keys\" not in argv:\n        return presets[DEFAULT_PRESET] + argv\n\n    return argv\n\n\ndef _expand_flag(\n    argv: list[str], flag: str, mapping: dict[str, list[str]]\n) -> list[str] | None:\n    \"\"\"Replace ``flag <name>`` in *argv* with the corresponding argv fragment from *mapping*.\"\"\"\n    if flag not in argv:\n        return None\n\n    idx: int = argv.index(flag)\n    name: str = argv[idx + 1]\n    if name not in mapping:\n        raise ValueError(\n            f\"Unknown value for {flag}: {name}. Available: {list(mapping.keys())}\"\n        )\n\n    return argv[:idx] + mapping[name] + argv[idx + 2 :]\n","sourceCodeStart":30,"sourceCodeEnd":53,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/debug_utils/comparator/preset.py#L30-L53","documentation":"Raised by _expand_flag in the comparator preset module when a preset-expanding CLI flag (e.g. --preset or similar mapped flag) is given a value that is not a key in the flag's mapping table. The error message lists the available values so the developer can pick a valid one. It is a strict whitelist lookup, so any typo or unsupported name fails immediately.","triggerScenarios":"Calling expand_preset(argv, mapping) with a command line like ['...','--flag','typo-name'] where 'typo-name' is not in mapping; e.g. passing an unknown preset name after the flag.","commonSituations":"Typos in preset names, presets renamed between versions, copy-pasting a preset name from old docs, or case mismatches (e.g. 'BF16' vs 'bf16').","solutions":["Check the error's 'Available:' list and use one of those exact keys","Check for case sensitivity or trailing whitespace in the value","If the value should be supported, add it to the mapping passed to expand_preset"],"exampleFix":"# before\nexpand_preset(['prog','--preset','fp8-e4m3'], mapping)\n# after\nexpand_preset(['prog','--preset','fp8_e4m3'], mapping)  # use a listed key","handlingStrategy":"validation","validationCode":"def check_flag_value(flag, name, mapping):\n    if name not in mapping:\n        raise SystemExit(f\"{flag}: unknown value {name!r}; available: {sorted(mapping)}\")","typeGuard":null,"tryCatchPattern":"try:\n    argv = expand_preset(argv, mapping)\nexcept ValueError as e:\n    print(e); sys.exit(2)","preventionTips":["Validate flag values against mapping.keys() before expanding","Keep preset name lists in one shared constant used by both docs and mapping"],"tags":["cli","preset","validation","whitelist"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}