sgl-project/sglang · error · ValueError

Invalid config pair (missing '='): {pair!r}

Error message

Invalid config pair (missing '='): {pair!r}

What it means

Raised by DumpConfig.from_kv_pairs when parsing a 'key=value' config string. The input is split on '=' via str.partition; if no '=' separator exists in a pair, the pair cannot be split into key and value and the parser rejects it immediately. This is a strict format check on kv-pair strings (used for CLI args and env-style config).

Source

Thrown at python/sglang/srt/debug_utils/dumper.py:113

        return raw

    @classmethod
    def from_kv_pairs(cls, pairs: Optional[List[str]]) -> "_BaseConfig":
        return cls(**cls._kv_pairs_to_dict(pairs))

    @classmethod
    def _kv_pairs_to_dict(cls, pairs: Optional[List[str]]) -> dict:
        if not pairs:
            return {}

        missing = object()
        defaults = {f.name: f.default for f in fields(cls)}
        result: dict = {}

        for pair in pairs:
            key, sep, value = pair.partition("=")
            if not sep:
                raise ValueError(f"Invalid config pair (missing '='): {pair!r}")
            default = defaults.get(key, missing)
            if default is missing:
                raise ValueError(
                    f"Unknown config key {key!r}. Valid keys: {sorted(defaults)}"
                )
            try:
                result[key] = cls._parse_env_value(value, default)
            except (ValueError, TypeError) as exc:
                field_type = type(default).__name__
                raise TypeError(f"{key}: expected {field_type}, got {value!r}") from exc

        return result


_DEFAULT_EXP_NAME_PREFIX = "dump_"


@dataclass(frozen=True)

View on GitHub (pinned to 0132848349)

Solutions

  1. Add an '=' and a value to every pair, e.g. 'phase=decode'
  2. Check for stray whitespace or a missing value in the pair string
  3. If you intended a boolean flag, still write 'flag=true' explicitly

Example fix

// before
cfg = DumpConfig.from_kv_pairs(["phase"])
// after
cfg = DumpConfig.from_kv_pairs(["phase=decode"])
Defensive patterns

Strategy: validation

Validate before calling

pairs = ["phase=decode"]
assert all("=" in p for p in pairs), f"missing '=' in {[p for p in pairs if '=' not in p]}"
cfg = DumpConfig.from_kv_pairs(pairs)

Try / catch

try:
    cfg = DumpConfig.from_kv_pairs(pairs)
except ValueError as e:
    if "missing '='" in str(e):
        raise SystemExit(f"bad config pair: {e}") from e
    raise

Prevention

When it happens

Trigger: Calling from_kv_pairs(['phase']) or passing a config string like 'phase' without '=value'; any list element lacking an '=' character.

Common situations: Typos in CLI flags or env vars consumed by the debug dumper (e.g. SGLANG_DUMP_CONFIG='phase' instead of 'phase=decode'); forgetting the value part of a pair.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/164a3a5c6916972a. Report an issue: GitHub.