From 6fa9a0e52b2c7989830571026ff6d3609aa5fb20 Mon Sep 17 00:00:00 2001 From: Chesars Date: Wed, 4 Mar 2026 19:23:37 -0300 Subject: [PATCH] fix(bfl): validate empty image list in edit handler Raise explicit error instead of letting IndexError propagate when an empty image list is passed to image_edit. --- .../llms/black_forest_labs/image_edit/handler.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/litellm/llms/black_forest_labs/image_edit/handler.py b/litellm/llms/black_forest_labs/image_edit/handler.py index bd7809ec4b6..9bf92c874fd 100644 --- a/litellm/llms/black_forest_labs/image_edit/handler.py +++ b/litellm/llms/black_forest_labs/image_edit/handler.py @@ -121,7 +121,12 @@ class BlackForestLabsImageEdit: # Transform request # Handle image list vs single image - image_input = image[0] if isinstance(image, list) and image else image + if isinstance(image, list): + if not image: + raise BlackForestLabsError(status_code=400, message="No image provided") + image_input = image[0] + else: + image_input = image data, _ = self.config.transform_image_edit_request( model=model, prompt=prompt or "", @@ -219,7 +224,12 @@ class BlackForestLabsImageEdit: ) # Transform request - image_input = image[0] if isinstance(image, list) and image else image + if isinstance(image, list): + if not image: + raise BlackForestLabsError(status_code=400, message="No image provided") + image_input = image[0] + else: + image_input = image data, _ = self.config.transform_image_edit_request( model=model, prompt=prompt or "",