sgl-project/sglang · error · ValueError

material URI base64 payload is empty

Error message

material URI base64 payload is empty

What it means

The base64 payload of a data/base64 material URI decoded to zero encoded characters, so there is nothing to write. The streaming decoder requires a non-empty payload.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py:627

    try:
        with partial_path.open("wb") as output:
            for value in _iter_base64_payload_bytes(uri, payload_start):
                encoded_size += 1
                if value == ord("="):
                    saw_padding = True
                    padding += 1
                    if padding > 2:
                        raise ValueError("material URI has invalid base64 padding")
                elif saw_padding:
                    raise ValueError("material URI has data after base64 padding")
                encoded_chunk.append(value)
                if len(encoded_chunk) == MINIMAX_H3_BASE64_DECODE_CHUNK_CHARS:
                    decoded_chunk = _decode_base64_chunk(encoded_chunk)
                    total += len(decoded_chunk)
                    output.write(decoded_chunk)
                    encoded_chunk.clear()
            if encoded_size == 0:
                raise ValueError("material URI base64 payload is empty")
            if encoded_size % 4 == 1 or (padding and encoded_size % 4):
                raise ValueError("material URI has an invalid base64 payload length")
            if encoded_chunk:
                encoded_chunk.extend(b"=" * (-len(encoded_chunk) % 4))
                decoded_chunk = _decode_base64_chunk(encoded_chunk)
                total += len(decoded_chunk)
                output.write(decoded_chunk)
        decoded_size = (encoded_size * 3) // 4 - padding
        if decoded_size <= 0:
            raise ValueError("material URI decoded payload is empty")
        if total != decoded_size:
            raise ValueError(
                f"MiniMax H3 base64 decoded size {total} != expected {decoded_size}"
            )
        partial_path.replace(output_path)
    except Exception:
        partial_path.unlink(missing_ok=True)
        output_path.unlink(missing_ok=True)

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the caller that produced the URI and fix the empty payload
  2. Fall back to a local file:// path if the asset exists on disk
  3. Log the raw URI length before passing it to the pipeline

Example fix

# before
uri = f"data:{mime};base64,{payload}"  # payload == ''
# after
if not payload:
    raise ValueError("empty asset")
uri = f"data:{mime};base64,{payload}"
Defensive patterns

Strategy: validation

Validate before calling

payload = uri.split(',', 1)[-1]
assert payload, 'empty base64 payload'

Try / catch

try:
    minimax_h3_localize_material_uri(batch, uri, ...)
except ValueError as e:
    if 'empty' in str(e): skip_or_reject(uri)

Prevention

When it happens

Trigger: minimax_h3_localize_material_uri receives 'data:image/png;base64,' or 'base64:' with nothing after the scheme prefix.

Common situations: Empty file encoded as a data URI, template bug producing an empty payload variable, upstream truncation of the URI string.

Related errors


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