{"record":{"id":"2806fce54aeb168e","repo":"sgl-project/sglang","slug":"image-placeholder-count-does-not-match-image-data","errorCode":null,"errorMessage":"Image placeholder count does not match image_data","messagePattern":"Image placeholder count does not match image_data","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/dots_note_omni.py","lineNumber":335,"sourceCode":"        pattern = re.compile(\n            f\"({native_pattern.pattern}|{_EXPANDED_VIDEO_MEDIA_RE.pattern})\"\n        )\n        rendered = []\n        last = 0\n\n        for match in pattern.finditer(input_text):\n            rendered.append(input_text[last : match.start()])\n            marker = match.group(0)\n            expanded_media = video_media.get(marker)\n            if expanded_media is not None:\n                modality, value = expanded_media\n            else:\n                modality = self.mm_tokens.get_modality_of_token(marker)\n                if modality == Modality.IMAGE:\n                    try:\n                        value = next(native_images)\n                    except StopIteration as exc:\n                        raise ValueError(\n                            \"Image placeholder count does not match image_data\"\n                        ) from exc\n                elif modality == Modality.AUDIO:\n                    try:\n                        value = next(native_audios)\n                    except StopIteration as exc:\n                        raise ValueError(\n                            \"Audio placeholder count does not match audio_data\"\n                        ) from exc\n                else:\n                    raise ValueError(f\"Unsupported dots omni media marker: {marker}\")\n\n            if modality == Modality.IMAGE:\n                ordered_images.append(value)\n                rendered.append(\n                    self.image_start_token + self.image_token + self.image_end_token\n                )\n            else:","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/dots_note_omni.py#L317-L353","documentation":"Raised by _merge_video_media when a rendered image marker is found in the prompt but the iterator over natively supplied image_data is exhausted. The number of image placeholders produced by video rendering must match the count of provided images.","triggerScenarios":"A video's preprocessed content emits more image markers than there are entries in the request's image_data list — e.g. the prompt/template adds image placeholders while image_data is empty or shorter.","commonSituations":"Chat template inserts extra image tokens for the video keyframes, but the client sent no image_data; or counts drift after editing the prompt. The bundled tests exercise this exact mismatch path.","solutions":["Align the number of image placeholders in the prompt/video content with len(image_data)","Pass keyframe images explicitly in image_data when your template references them","Update sglang — renderer/marker logic is covered by tests and may already be fixed for your template"],"exampleFix":"// before\nimage_data = []  # template has 2 image markers\n// after\nimage_data = [frame1, frame2]  # one per marker","handlingStrategy":"validation","validationCode":"img_markers = prompt.count(IMAGE_TOKEN) + rendered_video_image_markers\nassert img_markers == len(image_data), f'{img_markers} markers vs {len(image_data)} images'","typeGuard":null,"tryCatchPattern":"try:\n    await processor.process_mm_data_async(...)\nexcept ValueError as e:\n    if 'placeholder count does not match' in str(e):\n        # recount markers vs media and rebuild the request\n        ...","preventionTips":["Count markers vs media lengths before each request","Avoid hand-editing prompts containing media tokens"],"tags":["multimodal","placeholder-mismatch","images","valueerror"],"backgroundTag":"placeholder-count-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}