{"record":{"id":"842799566b69fb53","repo":"sgl-project/sglang","slug":"error-while-loading-data-data-str-e","errorCode":null,"errorMessage":"Error while loading data {data_str}: {e}","messagePattern":"Error while loading data (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/base_processor.py","lineNumber":876,"sourceCode":"                img, _ = load_image(data, cls.gpu_image_decode)\n                if isinstance(img, torch.Tensor):\n                    return img  # JPEG already decoded on GPU by nvJPEG\n                # PIL decodes lazily; do it here in the io worker so the decode\n                # doesn't run later on the event-loop thread.\n                if discard_alpha_channel and img.mode != \"RGB\":\n                    return img.convert(\"RGB\")\n                img.load()\n                return img\n            elif modality == Modality.VIDEO:\n                return load_video(data, frame_count_limit)\n            elif modality == Modality.AUDIO:\n                return load_audio(data, audio_sample_rate)\n\n        except CLIENT_MEDIA_EXCEPTIONS as e:\n            data_str = str(data)\n            if len(data_str) > 100:\n                data_str = data_str[:100] + \"...\"\n            raise ValueError(f\"Error while loading data {data_str}: {e}\") from e\n        except Exception as e:\n            data_str = str(data)\n            if len(data_str) > 100:\n                data_str = data_str[:100] + \"...\"\n            raise RuntimeError(f\"Error while loading data {data_str}: {e}\") from e\n\n    @staticmethod\n    def _get_preprocessed_input_format(data):\n        \"\"\"returns the detailed format if the provided data is already preprocessed.\n        returns none if the provided data is not preprocessed\n        \"\"\"\n        if not isinstance(data, dict):\n            return None\n        data_format = data.get(\"format\")\n        if isinstance(data_format, MultimodalInputFormat):\n            return data_format\n        if data_format in (\n            MultimodalInputFormat.PROCESSOR_OUTPUT.name,","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/base_processor.py#L858-L894","documentation":"_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.","triggerScenarios":"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.","commonSituations":"Expired presigned URLs; base64 payloads with header mistakes; unsupported codecs; wrong local paths in batch jobs.","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"],"exampleFix":"// before\nprocessor.process_mm_data_async(items=[bad_url], ...)\n// after\nassert requests.head(bad_url, timeout=5).status_code == 200\nprocessor.process_mm_data_async(items=[bad_url], ...)","handlingStrategy":"try-catch","validationCode":"import requests\nfor u in urls:\n    r = requests.head(u, timeout=5, allow_redirects=True)\n    assert r.status_code == 200, f\"unreachable media: {u}\"","typeGuard":null,"tryCatchPattern":"try:\n    await processor.process_mm_data_async(...)\nexcept ValueError as e:\n    if \"Error while loading data\" in str(e):\n        return client_error(str(e), cause=e.__cause__)  # map to 4xx\n    raise","preventionTips":["Pre-validate URLs/paths and base64 headers before submitting","Preserve e.__cause__ when re-wrapping to keep the real reason visible"],"tags":["multimodal","loading","http","input-validation"],"backgroundTag":"media-load-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}