sgl-project/sglang · error · ValueError

tar material reader returned too many bytes

Error message

tar material reader returned too many bytes

What it means

Defensive check: source.read(n) returned more bytes than the requested remaining count, which regular files should never do. Indicates an exotic filesystem/stream misbehaving or a bug.

Source

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

    output_path, partial_path = _material_output_paths(
        batch,
        condition_type=condition_type,
        condition_index=condition_index,
        source_name=member,
    )
    remaining = size
    try:
        with source_path.open("rb") as source, partial_path.open("wb") as output:
            source.seek(offset)
            while remaining:
                chunk = source.read(min(MINIMAX_H3_HTTP_READ_CHUNK_BYTES, remaining))
                if not chunk:
                    raise ValueError(
                        f"tar material payload is truncated with {remaining} bytes left"
                    )
                if len(chunk) > remaining:
                    raise ValueError("tar material reader returned too many bytes")
                output.write(chunk)
                remaining -= len(chunk)
        partial_path.replace(output_path)
    except Exception:
        partial_path.unlink(missing_ok=True)
        output_path.unlink(missing_ok=True)
        raise
    return str(output_path)


def _http_media_type(response: Any) -> str | None:
    headers = getattr(response, "headers", None)
    if headers is None:
        return None
    get_content_type = getattr(headers, "get_content_type", None)
    if callable(get_content_type):
        value = get_content_type()
    else:

View on GitHub (pinned to 0132848349)

Solutions

  1. Copy the tar to local disk and retry
  2. If using a FUSE/network mount, read via a plain local file instead
  3. Report a bug with the filesystem type if it reproduces on local ext4/xfs
Defensive patterns

Strategy: try-catch

Try / catch

except ValueError as e: copy archive to local disk and retry once

Prevention

When it happens

Trigger: A custom or network-backed file object (e.g. mounted FUSE) whose read() ignores the size argument when opened via _stream_tar_member_material.

Common situations: FUSE mounts, patched io classes in tests, or filesystem bugs; essentially unreachable with normal local files.

Related errors


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