sgl-project/sglang · error · ValueError

tar material offset_data and size must be non-negative

Error message

tar material offset_data and size must be non-negative

What it means

Raised when parsing a tar-member material URI for MiniMax H3: the header's offset_data and/or size parsed to a negative integer. The library refuses to build a byte-range read into the tar with negative bounds, since that would either read garbage or seek incorrectly.

Source

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

            ).decode("utf-8")
        )
    except Exception as exc:
        raise ValueError("tar material URI has an invalid encoded header") from exc
    if not isinstance(header, dict):
        raise ValueError("tar material URI header must be a JSON object")
    if header.get("schema") != "sglang.tar_member_ref/v1":
        raise ValueError(
            f"unsupported tar material header schema: {header.get('schema')!r}"
        )
    try:
        offset = int(header["offset_data"])
        size = int(header["size"])
    except (KeyError, TypeError, ValueError) as exc:
        raise ValueError(
            "tar material header requires integer offset_data and size"
        ) from exc
    if offset < 0 or size < 0:
        raise ValueError("tar material offset_data and size must be non-negative")
    return (
        Path(tar_path).expanduser(),
        offset,
        size,
        str(header.get("member") or "") or None,
    )


def _safe_suffix(value: str | None) -> str | None:
    if not value:
        return None
    suffix = Path(urllib.parse.urlsplit(value).path).suffix.lower()
    if suffix and len(suffix) <= 10 and suffix[1:].isalnum():
        return suffix
    return None


def _checked_material_file(path: Path, *, label: str) -> str:

View on GitHub (pinned to 0132848349)

Solutions

  1. Inspect the header JSON in the material URI and fix offset_data/size to non-negative integers
  2. Regenerate the tar material manifest with the packaging tool that produced it
  3. If the sentinel -1 means 'unknown', recompute the real offset/size from the tar member header

Example fix

// before
{"tar": "/data/mats.tar", "offset_data": -1, "size": -1}
// after
{"tar": "/data/mats.tar", "offset_data": 512, "size": 1048576}
Defensive patterns

Strategy: validation

Validate before calling

import json
def valid_tar_header(uri_header: str) -> bool:
    h = json.loads(uri_header)
    off, size = int(h["offset_data"]), int(h["size"])
    return off >= 0 and size >= 0

Try / catch

try:
    minimax_h3_localize_material_uri(uri)
except ValueError as e:
    if "must be non-negative" in str(e):
        logging.error("bad tar header in %s", uri)

Prevention

When it happens

Trigger: A material URI of the form referencing a tar member whose JSON header contains offset_data < 0 or size < 0 (e.g. hand-edited or generated by a buggy packaging step), passed to minimax_h3_localize_material_uri which streams via _stream_tar_member_material.

Common situations: Manually authored material manifests with typos (negative offsets), corrupted tar index files, or tooling that emits -1 as a sentinel for 'unknown' size.

Related errors


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