sgl-project/sglang · error · ValueError

{} must not be empty

Error message

{} must not be empty

What it means

A rank-scoped config field was given an empty list/tuple (or a comma string with no non-empty items); at least one entry is required so each rank can select one.

Source

Thrown at python/sglang/srt/mem_cache/storage/umbp/umbp_store.py:119


def _select_rank_config_value(
    value: Any,
    rank_index: int,
    field_name: str,
    cast_type,
    auto_increment_scalar: bool = False,
):
    if value is None:
        raise ValueError(f"{field_name} must not be None")

    candidates = value
    if isinstance(value, str) and "," in value:
        candidates = [item.strip() for item in value.split(",") if item.strip()]

    if isinstance(candidates, (list, tuple)):
        if not candidates:
            raise ValueError(f"{field_name} must not be empty")
        if rank_index >= len(candidates):
            raise ValueError(
                f"{field_name} has {len(candidates)} entries, but rank_index={rank_index}"
            )
        return cast_type(candidates[rank_index])

    selected = cast_type(candidates)
    if auto_increment_scalar:
        selected = cast_type(selected + rank_index)
    return selected


# extra_config is an explicit allow-list grouped by the scope in which each key
# takes effect (distributed mode is enabled by master_address). Advanced SPDK
# knobs outside this list go through the "spdk_passthrough" escape hatch.
_COMMON_EXTRA_KEYS = frozenset(
    {
        "dram_capacity_bytes",

View on GitHub (pinned to 0132848349)

Solutions

  1. Populate the list with one entry per rank (or a single scalar)
  2. If generating lists dynamically, guard against empty results and provide a default

Example fix

# before
extra['numa_nodes'] = [n for n in detected if n]  # -> []
# after
extra['numa_nodes'] = [n for n in detected if n] or [0]
Defensive patterns

Strategy: validation

Validate before calling

def rank_list(v):
    if isinstance(v, str):
        v = [s.strip() for s in v.split(',') if s.strip()]
    return list(v) if isinstance(v, (list, tuple)) else [v]
assert rank_list(extra['ssd_paths']), 'field must not be empty'

Prevention

When it happens

Trigger: Passing an empty list, (), or a string like ',' for a per-rank field (value parsed into zero candidates).

Common situations: Programmatically generated per-rank lists ending up empty (e.g. [x for x in ... where the source list was empty); JSON config with an empty array.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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