sgl-project/sglang · error · ValueError
Unknown value for {flag}: {name}. Available: {list(mapping.k
Error message
Unknown value for {flag}: {name}. Available: {list(mapping.keys())} What it means
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.
Source
Thrown at python/sglang/srt/debug_utils/comparator/preset.py:48
return expanded
if "--grouping-skip-keys" not in argv:
return presets[DEFAULT_PRESET] + argv
return argv
def _expand_flag(
argv: list[str], flag: str, mapping: dict[str, list[str]]
) -> list[str] | None:
"""Replace ``flag <name>`` in *argv* with the corresponding argv fragment from *mapping*."""
if flag not in argv:
return None
idx: int = argv.index(flag)
name: str = argv[idx + 1]
if name not in mapping:
raise ValueError(
f"Unknown value for {flag}: {name}. Available: {list(mapping.keys())}"
)
return argv[:idx] + mapping[name] + argv[idx + 2 :]
View on GitHub (pinned to 0132848349)
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
Example fix
# before expand_preset(['prog','--preset','fp8-e4m3'], mapping) # after expand_preset(['prog','--preset','fp8_e4m3'], mapping) # use a listed key
Defensive patterns
Strategy: validation
Validate before calling
def check_flag_value(flag, name, mapping):
if name not in mapping:
raise SystemExit(f"{flag}: unknown value {name!r}; available: {sorted(mapping)}") Try / catch
try:
argv = expand_preset(argv, mapping)
except ValueError as e:
print(e); sys.exit(2) Prevention
- Validate flag values against mapping.keys() before expanding
- Keep preset name lists in one shared constant used by both docs and mapping
When it happens
Trigger: 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.
Common situations: Typos in preset names, presets renamed between versions, copy-pasting a preset name from old docs, or case mismatches (e.g. 'BF16' vs 'bf16').
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown Ideogram 4 preset {preset!r}; expected one of {sorte
- unknown action keys {bad}; allowed keys are {sorted(_SANA_WM
- {option} must use component=value entries
- component_attention_backends must use component=backend entr
- Invalid --warmup-mode {self.warmup_mode!r}; expected one of
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/e55b0bc94714b1f0.
Report an issue: GitHub.