sgl-project/sglang · error · ValueError

Multimodal data is corrupted or cannot be decoded: {e}

Error message

Multimodal data is corrupted or cannot be decoded: {e}

What it means

The top-level ValueError raised by process_mm_data_async when the underlying MiMoProcessor.process call fails with a RuntimeError inside the IO executor. It aggregates any lower-level multimodal processing failure (video/image/audio decode or transform errors) into one 'corrupted or cannot be decoded' message with the cause chained.

Source

Thrown at python/sglang/srt/multimodal/processors/mimo_v2.py:2009

                            type="audio",
                            content=AudioInput(
                                audio=audio_source,
                            ),
                        )
                    )
            else:
                if text_part:
                    contents.append(Content(type="text", content=text_part))

        loop = asyncio.get_running_loop()
        try:
            input_sample = await loop.run_in_executor(
                self.io_executor,
                lambda: self.mimo_processor.process(contents, verbose=False),
            )
        except RuntimeError as e:
            logger.error(f"MiMo processor failed in process_mm_data_async: {e}")
            raise ValueError(f"Multimodal data is corrupted or cannot be decoded: {e}")

        input_ids = input_sample.input_ids.flatten()
        mm_items: list[MultimodalDataItem] = []
        if len(input_sample.image_thw_grids) > 0:
            mm_items.append(
                MultimodalDataItem(
                    modality=Modality.IMAGE,
                    feature=torch.cat(
                        [v.cpu() for v in input_sample.pixel_values], dim=0
                    ),
                    model_specific_data={
                        "image_grid_thw": torch.stack(input_sample.image_thw_grids)
                    },
                    offsets=self.get_mm_items_offset(
                        input_ids=input_ids,
                        mm_token_id=self.mimo_processor.image_token_id,
                    ),
                )

View on GitHub (pinned to 0132848349)

Solutions

  1. Read the {e} detail and the server log to find the true underlying error (video/image/audio specific) and fix that
  2. Pre-validate each multimodal item (openable/decodable) client-side before sending the request
  3. For batches, split the request to isolate the failing item
Defensive patterns

Strategy: try-catch

Validate before calling

# pre-flight: open every image, ffprobe every video, decode every audio before sending
for im in images: PIL.Image.open(BytesIO(im)).verify()
for v in videos: assert subprocess.run(['ffprobe','-v','error',v]).returncode == 0
for a in audios: assert isinstance(a, (str, bytes))

Try / catch

try:
    sample = await processor.process_mm_data_async(text, images=images, videos=videos, audios=audios)
except ValueError as e:
    if 'corrupted or cannot be decoded' in str(e):
        logger.error('underlying cause: %s', e)  # detail carries the real error
        return error_response(400, 'one or more attachments failed to decode')
    raise

Prevention

When it happens

Trigger: Any exception escaping mimo_processor.process during a multimodal request — typically the wrapped video failures (5786), image loading failures (5790), or transform errors (5789) surfacing as this ValueError at the API boundary.

Common situations: Users see this message instead of the specific cause; the actual error is in the server log line 'MiMo processor failed in process_mm_data_async' and in the {e} detail. Common with mixed-content requests where one item is bad.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/423a53881756b931. Report an issue: GitHub.