sgl-project/sglang · error · ValueError

row {i}: {e}

Error message

row {i}: {e}

What it means

A 2D int-list field passed validation of the outer list, but one row failed validate_list_i64_1d (not a list, contains non-ints, or mixed element types). The message embeds the failing row index and the inner error.

Source

Thrown at python/sglang/srt/utils/field_validators.py:79

    """Validates type: list[int] | list[list[int]] | None"""
    if v is None:
        # Accept None
        return v
    if not isinstance(v, list):
        raise ValueError(f"must be list or null; got {type(v).__name__}")
    if not v:
        # Accept empty list
        return v
    if isinstance(v[0], int):
        # Accept list[int]
        return validate_list_i64_1d(v)
    if isinstance(v[0], list):
        # Accept list[list[int]]
        for i, row in enumerate(v):
            try:
                validate_list_i64_1d(row)
            except ValueError as e:
                raise ValueError(f"row {i}: {e}") from None
        return v
    raise ValueError(f"elements must be int or list; got {type(v[0]).__name__}")

View on GitHub (pinned to 0132848349)

Solutions

  1. Look at row {i} in the message and fix the reported element type
  2. Ensure every row is a list of plain ints (no floats/strings/None)
  3. Validate the structure in your config loader before passing to sglang

Example fix

# before
value = [[1, 2], [3, 4.0]]
# after
value = [[1, 2], [3, 4]]
Defensive patterns

Strategy: validation

Validate before calling

def valid_2d(v):
    return all(isinstance(r, list) and all(isinstance(x, int) and not isinstance(x, bool) for x in r) for r in v)

Type guard

def is_i64_2d(v) -> TypeGuard[list[list[int]]]:
    return isinstance(v, list) and all(isinstance(r, list) and all(type(x) is int for x in r) for r in v)

Try / catch

try:
    validate_optional_list_i64_1d_2d(v)
except ValueError as e:
    raise ConfigError(str(e)) from e

Prevention

When it happens

Trigger: Passing list[list[int]] where a row contains floats, strings, booleans mixed with ints, or a row is not a list, e.g. [[1,2],[3,'4']].

Common situations: JSON configs where one row was hand-edited and contains a float like 1.0 or a string '2', or a row accidentally flattened.

Related errors


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