{"record":{"id":"2f1e96c5a5d67694","repo":"BerriAI/litellm","slug":"nova-canvas-image-edit-does-not-support-tuple-file","errorCode":null,"errorMessage":"Nova Canvas image edit does not support tuple FileTypes. Pass a file-like object, bytes, or a base64-encoded string.","messagePattern":"Nova Canvas image edit does not support tuple FileTypes\\. Pass a file-like object, bytes, or a base64-encoded string\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py","lineNumber":148,"sourceCode":"\ndef _file_types_to_b64(image: FileTypes | None) -> str:\n    \"\"\"Encode OpenAI image input to base64 string for Nova Canvas.\"\"\"\n    if image is None:\n        raise ValueError(\"Nova Canvas image edit requires an image input\")\n    if hasattr(image, \"read\") and callable(getattr(image, \"read\", None)):\n        if hasattr(image, \"seek\"):\n            image.seek(0)\n        image_bytes: Final = image.read()\n        return base64.b64encode(image_bytes).decode(\"utf-8\")\n    if isinstance(image, bytes):\n        return base64.b64encode(image).decode(\"utf-8\")\n    if isinstance(image, str):\n        return image\n    if isinstance(image, os.PathLike):\n        with open(image, \"rb\") as f:\n            return base64.b64encode(f.read()).decode(\"utf-8\")\n    if isinstance(image, tuple):\n        raise ValueError(\n            \"Nova Canvas image edit does not support tuple FileTypes. \"\n            \"Pass a file-like object, bytes, or a base64-encoded string.\"\n        )\n    return base64.b64encode(bytes(image)).decode(\"utf-8\")\n\n\ndef _supports_nova_canvas_image_edit_from_model_cost(model: str) -> bool:\n    \"\"\"\n    True when model_cost has supports_nova_canvas_image_edit for a resolved catalog key.\n\n    get_model_info / ModelInfoBase omit arbitrary JSON keys, so we read model_cost\n    directly (same idea as supports_* bare_entry fallback).\n    \"\"\"\n    import litellm as _litellm\n\n    if not model:\n        return False\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py#L130-L166","documentation":"OpenAI's FileTypes union includes (filename, content[, content_type]) tuples. Nova Canvas edits do not handle the tuple form, so after checking file-like, bytes, str, and PathLike inputs, _file_types_to_b64 explicitly raises ValueError for tuples instead of silently mis-encoding them.","triggerScenarios":"Passing image or mask as ('cat.png', b'...') or ('cat.png', open(...), 'image/png') to a bedrock nova-canvas image edit; some HTTP clients/SDKs build multipart files as tuples by default.","commonSituations":"Reusing tuple-style file payloads that other litellm file APIs accept; converting an OpenAI SDK call where files= accepts tuples; proxy middleware normalizing files to tuples.","solutions":["Unwrap the tuple client-side: pass the file object, bytes, base64 string, or filesystem path directly.","For (name, bytes) tuples use the second element; for (name, fileobj, mime) use the fileobj.","If using a proxy, ensure it forwards multipart file objects, not tuple descriptors."],"exampleFix":"# before\nimage = (\"cat.png\", png_bytes, \"image/png\")  # tuple -> ValueError\n# after\nimage = png_bytes            # bytes\n# or: image = open(\"cat.png\", \"rb\")\n# or: image = \"cat.png\"       # path","handlingStrategy":"type-guard","validationCode":"def unwrap_file_types(v):\n    \"\"\"Return a form nova-canvas accepts: file-like, bytes, str, or path.\"\"\"\n    if isinstance(v, tuple):\n        return v[1]  # (name, content[, mime]) -> content\n    return v","typeGuard":"def is_tuple_file_types(v: object) -> bool:\n    return isinstance(v, tuple)","tryCatchPattern":null,"preventionTips":["Normalize all file payloads through one unwrap helper before calling image_edit.","Prefer passing open(path,'rb') or raw bytes; avoid tuple forms entirely on bedrock edits.","Unit-test your client with each FileTypes shape you support."],"tags":["bedrock","nova-canvas","image-edit","file-types","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}