sgl-project/sglang · error · ValueError
Error while loading data {data_str}: {e}
Error message
Error while loading data {data_str}: {e} What it means
_load_single_item wraps known client-side media loading failures (CLIENT_MEDIA_EXCEPTIONS — HTTP errors, decode failures, missing files) into a ValueError with a truncated (100 char) repr of the offending data, chaining the original exception. It marks the failure as a caller-input problem rather than an internal bug.
Source
Thrown at python/sglang/srt/multimodal/processors/base_processor.py:876
img, _ = load_image(data, cls.gpu_image_decode)
if isinstance(img, torch.Tensor):
return img # JPEG already decoded on GPU by nvJPEG
# PIL decodes lazily; do it here in the io worker so the decode
# doesn't run later on the event-loop thread.
if discard_alpha_channel and img.mode != "RGB":
return img.convert("RGB")
img.load()
return img
elif modality == Modality.VIDEO:
return load_video(data, frame_count_limit)
elif modality == Modality.AUDIO:
return load_audio(data, audio_sample_rate)
except CLIENT_MEDIA_EXCEPTIONS as e:
data_str = str(data)
if len(data_str) > 100:
data_str = data_str[:100] + "..."
raise ValueError(f"Error while loading data {data_str}: {e}") from e
except Exception as e:
data_str = str(data)
if len(data_str) > 100:
data_str = data_str[:100] + "..."
raise RuntimeError(f"Error while loading data {data_str}: {e}") from e
@staticmethod
def _get_preprocessed_input_format(data):
"""returns the detailed format if the provided data is already preprocessed.
returns none if the provided data is not preprocessed
"""
if not isinstance(data, dict):
return None
data_format = data.get("format")
if isinstance(data_format, MultimodalInputFormat):
return data_format
if data_format in (
MultimodalInputFormat.PROCESSOR_OUTPUT.name,View on GitHub (pinned to 0132848349)
Solutions
- Check the chained cause (e.__cause__) for the real network/decode error and fix the source
- Verify the media URL/path/base64 is valid and reachable before submitting the request
- Retry with backoff only if the cause is transient (e.g. HTTP 503); otherwise correct the data
Example fix
// before processor.process_mm_data_async(items=[bad_url], ...) // after assert requests.head(bad_url, timeout=5).status_code == 200 processor.process_mm_data_async(items=[bad_url], ...)
Defensive patterns
Strategy: try-catch
Validate before calling
import requests
for u in urls:
r = requests.head(u, timeout=5, allow_redirects=True)
assert r.status_code == 200, f"unreachable media: {u}" Try / catch
try:
await processor.process_mm_data_async(...)
except ValueError as e:
if "Error while loading data" in str(e):
return client_error(str(e), cause=e.__cause__) # map to 4xx
raise Prevention
- Pre-validate URLs/paths and base64 headers before submitting
- Preserve e.__cause__ when re-wrapping to keep the real reason visible
When it happens
Trigger: Loading an image/audio/video item whose URL 404s, whose bytes fail to decode, or whose local path doesn't exist — i.e. any client-classified exception inside the per-item loader.
Common situations: Expired presigned URLs; base64 payloads with header mistakes; unsupported codecs; wrong local paths in batch jobs.
Related errors
- An exception occurred while loading {modality.name} data at
- Unsupported image type: {type(image)}
- When using multiple prompts with multiple input images, prov
- {key}.position_ids is required
- {key}.{field} is required
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/842799566b69fb53.
Report an issue: GitHub.