sgl-project/sglang · error · ValueError
data URI header is too large
Error message
data URI header is too large
What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py:99
paths = registry.pop(owner, [])
if isinstance(paths, (list, tuple)):
for path in paths:
shutil.rmtree(str(path), ignore_errors=True)
if not registry:
batch.extra.pop(MINIMAX_H3_TEMP_DIRS_EXTRA_KEY, None)
if owners is None or "material" in selected:
batch.extra.pop(MINIMAX_H3_MATERIAL_CACHE_EXTRA_KEY, None)
batch.extra.pop(MINIMAX_H3_MATERIAL_PROBE_EXTRA_KEY, None)
def _base64_uri_payload_start(uri: str) -> tuple[int, str | None]:
media_type = None
if uri.startswith("data:"):
separator = uri.find(",")
if separator < 0:
raise ValueError("data URI must contain a comma separator")
if separator > MINIMAX_H3_BASE64_HEADER_MAX_CHARS:
raise ValueError("data URI header is too large")
header = uri[:separator]
if ";base64" not in header:
raise ValueError("data URI must use ;base64 encoding")
media_type = header[5:].split(";", 1)[0].lower() or None
payload_start = separator + 1
elif uri.startswith("base64://"):
payload_start = len("base64://")
separator = uri.find(",", payload_start)
if separator >= 0:
if separator - payload_start > MINIMAX_H3_BASE64_HEADER_MAX_CHARS:
raise ValueError("base64 URI header is too large")
header = uri[payload_start:separator]
media_type = header.split(";", 1)[0].lower() or None
payload_start = separator + 1
else: # pragma: no cover - guarded by the caller
raise ValueError("not a base64 material URI")
return payload_start, media_type
View on GitHub (pinned to 0132848349)
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
Example fix
// before uri = "data:image/png;base64" + payload # missing comma -> whole string is header // after uri = "data:image/png;base64," + payload
Defensive patterns
Strategy: validation
Validate before calling
sep = uri.find(',')
if uri.startswith('data:') and (sep < 0 or sep > MINIMAX_H3_BASE64_HEADER_MAX_CHARS):
raise ValueError('data URI header missing or too large') Type guard
def data_uri_header_ok(uri: str, cap: int) -> bool:
sep = uri.find(',')
return 0 < sep <= cap Prevention
- Keep headers minimal ('data:image/png;base64')
- Treat oversized headers as a missing-comma bug
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- data URI must contain a comma separator
- data URI must use ;base64 encoding
- base64 URI header is too large
- tar material URI encoded header is too large
- material URI has an invalid percent escape
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b54da1635781ffd9.
Report an issue: GitHub.