{"record":{"id":"567d2bc8b76ffd11","repo":"sgl-project/sglang","slug":"base64-uri-header-is-too-large","errorCode":null,"errorMessage":"base64 URI header is too large","messagePattern":"base64 URI 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":110,"sourceCode":"def _base64_uri_payload_start(uri: str) -> tuple[int, str | None]:\n    media_type = None\n    if uri.startswith(\"data:\"):\n        separator = uri.find(\",\")\n        if separator < 0:\n            raise ValueError(\"data URI must contain a comma separator\")\n        if separator > MINIMAX_H3_BASE64_HEADER_MAX_CHARS:\n            raise ValueError(\"data URI header is too large\")\n        header = uri[:separator]\n        if \";base64\" not in header:\n            raise ValueError(\"data URI must use ;base64 encoding\")\n        media_type = header[5:].split(\";\", 1)[0].lower() or None\n        payload_start = separator + 1\n    elif uri.startswith(\"base64://\"):\n        payload_start = len(\"base64://\")\n        separator = uri.find(\",\", payload_start)\n        if separator >= 0:\n            if separator - payload_start > MINIMAX_H3_BASE64_HEADER_MAX_CHARS:\n                raise ValueError(\"base64 URI header is too large\")\n            header = uri[payload_start:separator]\n            media_type = header.split(\";\", 1)[0].lower() or None\n            payload_start = separator + 1\n    else:  # pragma: no cover - guarded by the caller\n        raise ValueError(\"not a base64 material URI\")\n    return payload_start, media_type\n\n\ndef _iter_base64_payload_bytes(uri: str, payload_start: int):\n    \"\"\"Yield validated, unquoted base64 bytes without copying the payload.\"\"\"\n\n    index = payload_start\n    while index < len(uri):\n        character = uri[index]\n        if character == \"%\":\n            if index + 2 >= len(uri):\n                raise ValueError(\"material URI has an invalid percent escape\")\n            try:","sourceCodeStart":92,"sourceCodeEnd":128,"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#L92-L128","documentation":"For 'base64://' scheme URIs, an optional media-type segment may precede a ','; that segment must stay within MINIMAX_H3_BASE64_HEADER_MAX_CHARS. The error fires when the comma-delimited header portion of a base64:// URI exceeds the cap.","triggerScenarios":"A base64:// URI whose text before the first ',' is longer than the header cap — typically because the comma separator was lost and the base64 payload itself is being counted as header.","commonSituations":"Malformed base64:// URIs where the payload was appended without the ',' separator, or a media-type segment stuffed with junk.","solutions":["Ensure the optional header segment is short and followed by ',' before the payload","If no media type is needed, emit 'base64://<payload>' with no comma at all","Validate comma position (if present, must be within the header cap) at ingestion"],"exampleFix":"// before\nuri = \"base64://image/png\" + payload  # missing comma\n// after\nuri = \"base64://image/png,\" + payload  # or simply \"base64://\" + payload","handlingStrategy":"validation","validationCode":"if uri.startswith('base64://'):\n    sep = uri.find(',', len('base64://'))\n    if sep >= 0 and sep - len('base64://') > MINIMAX_H3_BASE64_HEADER_MAX_CHARS:\n        raise ValueError('base64 URI header too large')","typeGuard":"def base64_uri_header_ok(uri: str, cap: int) -> bool:\n    sep = uri.find(',', len('base64://'))\n    return sep < 0 or sep - len('base64://') <= cap","tryCatchPattern":null,"preventionTips":["Prefer headerless 'base64://<payload>' when media type is unknown","Check comma placement when building URIs"],"tags":["minimax-h3","base64-uri","header-limit","material-io"],"backgroundTag":"malformed-data-uri","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}