{"record":{"id":"45129dcf32ba9c87","repo":"Comfy-Org/ComfyUI","slug":"no-images-provided-to-create-image-parts-at-least","errorCode":null,"errorMessage":"No images provided to create_image_parts; at least one image is required.","messagePattern":"No images provided to create_image_parts; at least one image is required\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_gemini.py","lineNumber":101,"sourceCode":"    )\n    \"\"\",\n)\n\n\nasync def create_image_parts(\n    cls: type[IO.ComfyNode],\n    images: Input.Image | list[Input.Image],\n    image_limit: int = 0,\n) -> list[GeminiPart]:\n    image_parts: list[GeminiPart] = []\n    if image_limit < 0:\n        raise ValueError(\"image_limit must be greater than or equal to 0 when creating Gemini image parts.\")\n\n    # Accept either a single (possibly-batched) tensor or a list of them; share URL budget across all.\n    images_list: list[Input.Image] = images if isinstance(images, list) else [images]\n    total_images = sum(get_number_of_images(img) for img in images_list)\n    if total_images <= 0:\n        raise ValueError(\"No images provided to create_image_parts; at least one image is required.\")\n\n    # If image_limit == 0 --> use all images; otherwise clamp to image_limit.\n    effective_max = total_images if image_limit == 0 else min(total_images, image_limit)\n\n    # Number of images we'll send as URLs (fileData)\n    num_url_images = min(effective_max, 10)  # Vertex API max number of image links\n    upload_kwargs: dict = {\"wait_label\": \"Uploading reference images\"}\n    if effective_max > num_url_images:\n        # Split path (e.g. 11+ images): suppress per-image counter to avoid a confusing dual-fraction label.\n        upload_kwargs = {\n            \"wait_label\": f\"Uploading reference images ({num_url_images}+)\",\n            \"show_batch_index\": False,\n        }\n    reference_images_urls = await upload_images_to_comfyapi(\n        cls,\n        images_list,\n        max_images=num_url_images,\n        **upload_kwargs,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_gemini.py#L83-L119","documentation":"Raised by create_image_parts() when the total image count across all supplied tensors is zero — either an empty list was passed or every tensor has get_number_of_images() == 0. It guards against building a content array with no image parts before any upload happens.","triggerScenarios":"create_image_parts called with an empty list, or with image tensors whose first dimension is 0 (empty batch); typically when an upstream node produced a zero-length batch.","commonSituations":"An image-picker/filter upstream legitimately matched zero images; a Load Image batch loaded an empty directory; upstream node error swallowed into an empty tensor; branching workflows where one branch has no images selected.","solutions":["Verify the upstream image source actually outputs at least one image (inspect it with a Preview Image node).","If a filter/picker can legitimately yield zero images, gate the Gemini call on the count (e.g. ImagePadForOutpaint-style switch or a conditional bypass).","Fix the empty batch at its source (correct folder, correct mask selection) rather than patching here."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def has_any_images(images) -> bool:\n    imgs = images if isinstance(images, list) else [images]\n    return sum(img.shape[0] if img.ndim == 4 else 1 for img in imgs) > 0\n\n# skip or bypass the Gemini call when has_any_images(images) is False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Preview upstream image outputs before Gemini nodes in branching workflows.","Guard optional-image paths with a count check so zero-image branches skip the call."],"tags":["comfyui","gemini","validation","empty-input","image-batch"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}