{"record":{"id":"ed6b9d0a96b1ca1c","repo":"sgl-project/sglang","slug":"tar-material-payload-is-truncated-with-remaining","errorCode":null,"errorMessage":"tar material payload is truncated with {remaining} bytes left","messagePattern":"tar material payload is truncated with (.+?) bytes left","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":685,"sourceCode":"        raise ValueError(\n            f\"tar material payload is truncated: expected {size} bytes, \"\n            f\"only {available} available\"\n        )\n\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","sourceCodeStart":667,"sourceCodeEnd":703,"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#L667-L703","documentation":"While streaming the member bytes, read() returned empty before the declared size was consumed — the file shrank or hit EOF mid-read despite passing the earlier stat check.","triggerScenarios":"The tar file is truncated or concurrently modified between the stat check and the streaming read loop.","commonSituations":"Archive still being written when the request arrives; NFS/volume flakiness; disk-full truncation.","solutions":["Wait for archive writes to complete before serving requests (write to temp then rename)","Re-verify file size with checksums before the run","Pin a stable snapshot/immutable path for the archive"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if source.stat().st_size < offset + size: wait_or_repair()","typeGuard":null,"tryCatchPattern":"except ValueError as e:\n    if 'truncated with' in str(e): retry_after_archive_settles()","preventionTips":["Publish archives via atomic temp+rename","Never serve while the tar is still being written"],"tags":["tar","truncation","race-condition"],"backgroundTag":"file-truncated","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}