{"record":{"id":"c8319b84c194cfc2","repo":"sgl-project/sglang","slug":"tar-material-reader-returned-too-many-bytes","errorCode":null,"errorMessage":"tar material reader returned too many bytes","messagePattern":"tar material reader returned too many bytes","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py","lineNumber":689,"sourceCode":"\n    output_path, partial_path = _material_output_paths(\n        batch,\n        condition_type=condition_type,\n        condition_index=condition_index,\n        source_name=member,\n    )\n    remaining = size\n    try:\n        with source_path.open(\"rb\") as source, partial_path.open(\"wb\") as output:\n            source.seek(offset)\n            while remaining:\n                chunk = source.read(min(MINIMAX_H3_HTTP_READ_CHUNK_BYTES, remaining))\n                if not chunk:\n                    raise ValueError(\n                        f\"tar material payload is truncated with {remaining} bytes left\"\n                    )\n                if len(chunk) > remaining:\n                    raise ValueError(\"tar material reader returned too many bytes\")\n                output.write(chunk)\n                remaining -= len(chunk)\n        partial_path.replace(output_path)\n    except Exception:\n        partial_path.unlink(missing_ok=True)\n        output_path.unlink(missing_ok=True)\n        raise\n    return str(output_path)\n\n\ndef _http_media_type(response: Any) -> str | None:\n    headers = getattr(response, \"headers\", None)\n    if headers is None:\n        return None\n    get_content_type = getattr(headers, \"get_content_type\", None)\n    if callable(get_content_type):\n        value = get_content_type()\n    else:","sourceCodeStart":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py#L671-L707","documentation":"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.","triggerScenarios":"A custom or network-backed file object (e.g. mounted FUSE) whose read() ignores the size argument when opened via _stream_tar_member_material.","commonSituations":"FUSE mounts, patched io classes in tests, or filesystem bugs; essentially unreachable with normal local files.","solutions":["Copy the tar to local disk and retry","If using a FUSE/network mount, read via a plain local file instead","Report a bug with the filesystem type if it reproduces on local ext4/xfs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"except ValueError as e: copy archive to local disk and retry once","preventionTips":["Avoid serving tar materials directly off FUSE/network mounts"],"tags":["tar","io-contract","defensive"],"backgroundTag":"io-read-contract-violation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}