{"record":{"id":"8a493a5c39f53119","repo":"sgl-project/sglang","slug":"tar-material-uri-encoded-header-is-too-large","errorCode":null,"errorMessage":"tar material URI encoded header is too large","messagePattern":"tar material URI encoded header is too large","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":163,"sourceCode":"            )\n        yield value\n\n\ndef _parse_tar_member_uri(uri: str) -> tuple[Path, int, int, str | None]:\n    if uri.startswith(\"tar+offset://\"):\n        prefix = \"tar+offset://\"\n    elif uri.startswith(\"tar+b64header://\"):\n        prefix = \"tar+b64header://\"\n    else:\n        raise ValueError(\"unsupported tar material URI\")\n    try:\n        tar_path, encoded_header = uri[len(prefix) :].rsplit(\":\", 1)\n    except ValueError as exc:\n        raise ValueError(\n            \"tar material URI must contain '<tar_path>:<encoded_header>'\"\n        ) from exc\n    if len(encoded_header) > MINIMAX_H3_TAR_HEADER_MAX_ENCODED_CHARS:\n        raise ValueError(\"tar material URI encoded header is too large\")\n    padded = encoded_header + \"=\" * (-len(encoded_header) % 4)\n    try:\n        header = json.loads(\n            base64.b64decode(\n                padded.encode(\"ascii\"), altchars=b\"-_\", validate=True\n            ).decode(\"utf-8\")\n        )\n    except Exception as exc:\n        raise ValueError(\"tar material URI has an invalid encoded header\") from exc\n    if not isinstance(header, dict):\n        raise ValueError(\"tar material URI header must be a JSON object\")\n    if header.get(\"schema\") != \"sglang.tar_member_ref/v1\":\n        raise ValueError(\n            f\"unsupported tar material header schema: {header.get('schema')!r}\"\n        )\n    try:\n        offset = int(header[\"offset_data\"])\n        size = int(header[\"size\"])","sourceCodeStart":145,"sourceCodeEnd":181,"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#L145-L181","documentation":"The base64-encoded JSON header segment of a tar material URI must not exceed MINIMAX_H3_TAR_HEADER_MAX_ENCODED_CHARS. This bounds memory/parse cost and rejects corrupted URIs where the header and path got swapped or the header is garbage.","triggerScenarios":"A tar+b64header:// URI whose encoded header segment exceeds the cap — usually because rsplit(':',1) grabbed the wrong segment (path containing ':' pushing a huge segment into the header) or a corrupted URI.","commonSituations":"Tar paths containing ':' making the split ambiguous, corrupt URIs after transport truncation, or headers accidentally embedding large payloads.","solutions":["Keep the JSON header minimal (schema, offset_data, size) so the encoded form stays small","If the tar path may contain ':', use rsplit semantics consistently on the producer side or forbid ':' in paths","Regenerate the URI from a known-good tar member reference"],"exampleFix":"// before\nheader = {\"schema\": \"...\", \"offset_data\": 0, \"size\": n, \"blob\": giant_payload}\n// after\nheader = {\"schema\": \"sglang.tar_member_ref/v1\", \"offset_data\": offset, \"size\": size}","handlingStrategy":"validation","validationCode":"encoded = uri.split('://', 1)[1].rsplit(':', 1)[1]\nassert len(encoded) <= MINIMAX_H3_TAR_HEADER_MAX_ENCODED_CHARS","typeGuard":"def tar_header_size_ok(uri: str, cap: int) -> bool:\n    try:\n        encoded = uri.split('://', 1)[1].rsplit(':', 1)[1]\n    except (IndexError, ValueError):\n        return False\n    return len(encoded) <= cap","tryCatchPattern":null,"preventionTips":["Keep headers minimal (schema/offset/size only)","Avoid ':' in tar paths to keep rsplit unambiguous"],"tags":["minimax-h3","tar-uri","header-limit","material-io"],"backgroundTag":"malformed-uri-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}