← Back to DAGDA | Support | Source: https://github.com/BerriAI/litellm/pull/52529
Skip to content

fix(fal_ai): raise BadRequestError when an image edit request has no image - #52529

Open
shadowmodder wants to merge 4 commits into
BerriAI:mainfrom
shadowmodder:shadowmodder/fix/fal-ai-image-edit-bad-request
Open

shadowmodder wants to merge 4 commits into
BerriAI:mainfrom
shadowmodder:shadowmodder/fix/fal-ai-image-edit-bad-request

Conversation

@shadowmodder

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • Fal AI image edit with no input image raised a bare ValueError, which the proxy surfaces as HTTP 500
  • A 500 reads as retryable, so a client that forgot the image keeps resending a request that can never succeed

How it solves it:

User Flow

Before: a caller sends an image edit request with no image

  1. The operator runs the proxy with a Fal AI deployment
  2. The caller calls litellm.image_edit with image=[] or sends the equivalent request to /v1/images/edits with no image attached
  3. A raw ValueError propagates and the proxy reports HTTP 500

After: the same request fails as a client error

  1. The operator runs the same proxy
  2. The caller sends the same request
  3. The transformation raises litellm.BadRequestError and the proxy reports HTTP 400

Relevant issues

Fixes #52525

Screenshots / Proof of Fix

E2E exception at base da8c02b. The full diff is two exception raises in the request transformation, and the contract is the exception type and status code the transformation raises, which the checks below prove directly. No Fal AI API key is available in my sandbox, so no live provider call was run.

Reproduction script (calls transform_image_edit_request on both configs with image=[] and image=None, 4 cases):

  • Before (base da8c02b): 4 of 4 cases raised a bare ValueError
  • After: 4 of 4 cases raised litellm.BadRequestError with status_code 400

Tests:

  • pytest tests/unit/llms/fal_ai/image_edit/ : 45 passed
  • Mutation check: with only the two source files reverted, the 4 requires_an_image test cases fail. With the fix restored, all 45 pass
  • The existing test that pinned the old ValueError was updated to assert BadRequestError and status 400, and the same regression test was added for the flux lora depth config
  • ruff check and ruff format --check are clean on all 4 changed files

One scope note: the flux lora depth config has a separate check that raises ValueError when more than one image is given. The issue does not name that check, so this PR leaves it unchanged.

Type

Bug Fix

…image

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
…image

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
…image

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
…image

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
@veria-ai

veria-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fal AI image edit raises a bare ValueError instead of a 400 when no image is given

1 participant