{"record":{"id":"487fa7b5ccc58e95","repo":"sgl-project/sglang","slug":"cosmos3-i2v-image-list-is-empty","errorCode":null,"errorMessage":"Cosmos3 I2V image list is empty","messagePattern":"Cosmos3 I2V image list is empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py","lineNumber":185,"sourceCode":"        if isinstance(video_path, list):\n            video_path = video_path[0] if video_path else None\n\n        if image_path and video_path:\n            raise ValueError(\n                \"Cosmos3 accepts either --image-path (I2V) or --video-path \"\n                \"(V2V), not both\"\n            )\n\n        target_h, target_w = batch.height, batch.width\n\n        if image_path is not None:\n            image_sources = (\n                list(image_path)\n                if isinstance(image_path, (list, tuple))\n                else [image_path]\n            )\n            if not image_sources:\n                raise ValueError(\"Cosmos3 I2V image list is empty\")\n            tensors: list[torch.Tensor] = []\n            for src in image_sources:\n                image = load_image(src)\n                image = _resize_crop_pil(image, target_w, target_h)\n                tensors.append(_pil_to_normalized_tensor(image))\n            batch.preprocessed_image = torch.stack(tensors, dim=0).contiguous()\n            self.log_info(\n                f\"Preprocessed {len(tensors)} conditioning image(s) to \"\n                f\"{target_w}x{target_h}\"\n            )\n            return batch\n\n        if isinstance(video_path, str) and video_path:\n            frames = load_video(video_path)\n            if not frames:\n                raise ValueError(f\"No frames decoded from video: {video_path!r}\")\n\n            keep = (","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py#L167-L203","documentation":"Cosmos3 I2V mode builds a batch of conditioning images from image_path, but after normalization the source list is empty (e.g. image_path == []). Rather than stacking a zero-size tensor, the stage fails fast.","triggerScenarios":"Passing image_path as an empty list (or a list containing only falsy entries) while not in action-policy mode, so image_sources ends up empty in the I2V branch.","commonSituations":"Programmatic clients building image lists from glob/dataset iteration that return zero matches; a UI sending [] when no image is selected; default mutable argument leaking an empty list.","solutions":["Pass at least one valid image path: image_path=[\"frame.jpg\"] or image_path=\"frame.jpg\"","If images are optional for your flow, omit image_path entirely instead of sending []","Fix upstream list construction (glob filters, dataset splits) that can yield zero entries"],"exampleFix":"# before\nreq = {\"image_path\": [], \"prompt\": \"...\"}\n# after\nreq = {\"image_path\": [\"input/frame.jpg\"], \"prompt\": \"...\"}","handlingStrategy":"validation","validationCode":"imgs = req.get(\"image_path\") or []\nimgs = [imgs] if isinstance(imgs, str) else list(imgs)\nassert imgs, \"I2V requires at least one image\"","typeGuard":"def nonempty_image_list(image_path) -> bool:\n    if image_path is None: return False\n    items = [image_path] if isinstance(image_path, str) else list(image_path)\n    return len(items) > 0 and all(items)","tryCatchPattern":null,"preventionTips":["Validate glob/dataset results before building requests"],"tags":["cosmos3","i2v","empty-list","image-input"],"backgroundTag":"empty-input-list","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}