{"record":{"id":"b54da1635781ffd9","repo":"sgl-project/sglang","slug":"data-uri-header-is-too-large","errorCode":null,"errorMessage":"data URI header is too large","messagePattern":"data 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":99,"sourceCode":"            paths = registry.pop(owner, [])\n            if isinstance(paths, (list, tuple)):\n                for path in paths:\n                    shutil.rmtree(str(path), ignore_errors=True)\n        if not registry:\n            batch.extra.pop(MINIMAX_H3_TEMP_DIRS_EXTRA_KEY, None)\n    if owners is None or \"material\" in selected:\n        batch.extra.pop(MINIMAX_H3_MATERIAL_CACHE_EXTRA_KEY, None)\n        batch.extra.pop(MINIMAX_H3_MATERIAL_PROBE_EXTRA_KEY, None)\n\n\ndef _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","sourceCodeStart":81,"sourceCodeEnd":117,"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#L81-L117","documentation":"For data: URIs, the header (everything before the ',') must not exceed MINIMAX_H3_BASE64_HEADER_MAX_CHARS. This bounds-check prevents absurdly long headers from being parsed and acts as a lightweight abuse guard against malformed or hostile URIs.","triggerScenarios":"A data: URI whose media-type/parameter header exceeds the configured character cap, e.g. a header stuffed with junk parameters or a URI where the comma appears very late because the payload was concatenated onto the header.","commonSituations":"Malformed URIs missing the comma so the whole payload counts as header, prompt-injected material URIs with huge headers, or a comma lost during JSON transport.","solutions":["Shorten the data URI header to a plain 'data:image/png;base64' style","Check the comma position: uri.find(',') must be present and small; if missing, fix URI generation","Sanitize/validate material URIs at request ingestion with the same header cap"],"exampleFix":"// before\nuri = \"data:image/png;base64\" + payload  # missing comma -> whole string is header\n// after\nuri = \"data:image/png;base64,\" + payload","handlingStrategy":"validation","validationCode":"sep = uri.find(',')\nif uri.startswith('data:') and (sep < 0 or sep > MINIMAX_H3_BASE64_HEADER_MAX_CHARS):\n    raise ValueError('data URI header missing or too large')","typeGuard":"def data_uri_header_ok(uri: str, cap: int) -> bool:\n    sep = uri.find(',')\n    return 0 < sep <= cap","tryCatchPattern":null,"preventionTips":["Keep headers minimal ('data:image/png;base64')","Treat oversized headers as a missing-comma bug"],"tags":["minimax-h3","data-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"}