{"record":{"id":"c6494e340053fb17","repo":"BerriAI/litellm","slug":"unsupported-image-type-for-vertex-ai-imagen-image","errorCode":null,"errorMessage":"Unsupported image type for Vertex AI Imagen image edit.","messagePattern":"Unsupported image type for Vertex AI Imagen image edit\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/image_edit/vertex_imagen_transformation.py","lineNumber":298,"sourceCode":"                    \"maskMode\": \"MASK_MODE_USER_PROVIDED\",\n                    \"dilation\": 0.03,  # Default dilation value (not configurable via OpenAI API)\n                },\n            }\n            reference_images.append(mask_reference)\n\n        return reference_images\n\n    def _read_all_bytes(self, image: Any, depth: int = 0, max_depth: int = DEFAULT_MAX_RECURSE_DEPTH) -> bytes:\n        if depth > max_depth:\n            raise ValueError(\n                f\"Max recursion depth {max_depth} reached while reading image bytes for Vertex AI Imagen image edit.\"\n            )\n\n        if isinstance(image, (list, tuple)):\n            for item in image:\n                if item is not None:\n                    return self._read_all_bytes(item, depth=depth + 1, max_depth=max_depth)\n            raise ValueError(\"Unsupported image type for Vertex AI Imagen image edit.\")\n\n        if isinstance(image, dict):\n            for key in (\"data\", \"bytes\", \"content\"):\n                if key in image and image[key] is not None:\n                    value = image[key]\n                    if isinstance(value, str):\n                        try:\n                            return base64.b64decode(value)\n                        except Exception:\n                            continue\n                    return self._read_all_bytes(value, depth=depth + 1, max_depth=max_depth)\n            if \"path\" in image:\n                return self._read_all_bytes(image[\"path\"], depth=depth + 1, max_depth=max_depth)\n\n        if isinstance(image, bytes):\n            return image\n        if isinstance(image, bytearray):\n            return bytes(image)","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/image_edit/vertex_imagen_transformation.py#L280-L316","documentation":"Inside _read_all_bytes, when the value is a list or tuple the code recurses into the first non-None element; if every element is None (or the container is empty) there is nothing to read and this ValueError is raised. It means a container reached the byte reader but carried no usable payload — distinct from the top-level 'image is None' check in transform_image_edit_request.","triggerScenarios":"image=[None] or image=[None, None] passed as the images list; the mask optional param set to an empty tuple (); a dict {'data': [None]} recursing into a None-only list.","commonSituations":"Placeholder lists filled with None by an earlier failed download; default arguments like image=[None] used to satisfy a type signature; multi-upload forms where every file failed to read and None was substituted.","solutions":["Filter Nones and empties out of image lists before calling litellm","Replace failed downloads with a hard error instead of None placeholders","Validate that at least one element is bytes/str-in-dict/file-like before sending"],"exampleFix":"# before\nresp = litellm.image_edit(\n    model='vertex_ai/imagen-3.0-capability-001',\n    prompt='edit',\n    image=[failed_download, None],  # both None-ish -> raises\n)\n\n# after\nimgs = [img for img in downloads if img is not None]\nif not imgs:\n    raise ValueError('all image downloads failed')\nresp = litellm.image_edit(\n    model='vertex_ai/imagen-3.0-capability-001',\n    prompt='edit',\n    image=imgs,\n)","handlingStrategy":"validation","validationCode":"def has_payload(container) -> bool:\n    return any(item is not None for item in (container or []))\n\nif isinstance(image, (list, tuple)):\n    assert has_payload(image), 'image container has no usable entries'","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_edit(model='vertex_ai/imagen-...', prompt=p, image=image)\nexcept ValueError as e:\n    if 'Unsupported image type' in str(e) and isinstance(image, (list, tuple)):\n        raise ValueError('image list contained only None entries') from e\n    raise","preventionTips":["Filter Nones from every image list before it reaches litellm","Never use [None] placeholders to satisfy list-typed parameters","Log when image downloads fail so empty containers are visible upstream"],"tags":["vertex-ai","imagen","image-edit","input-validation","unsupported-type","empty-input"],"backgroundTag":"unsupported-input-type","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}