fix(bedrock): prevent double UUID in create_file S3 key (#21650)

In create_file for Bedrock, get_complete_file_url is called twice:
once in the sync handler (generating UUID-1 for api_base) and once
inside transform_create_file_request (generating UUID-2 for the
actual S3 upload). The Bedrock provider correctly writes UUID-2 into
litellm_params["upload_url"], but the sync handler unconditionally
overwrites it with api_base (UUID-1). This causes the returned
file_id to point to a non-existent S3 key.

Fix: only set upload_url to api_base when transform_create_file_request
has not already set it, preserving the Bedrock provider's value.

Closes #21546
This commit is contained in:
Zhenting Huang 2026-02-21 16:50:40 +08:00 • committed by GitHub
parent 647ea3bfcb
commit d53ea88598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3014,8 +3014,11 @@ class BaseLLMHTTPHandler:
raise ValueError(f"Unsupported transformed_request type: {type(transformed_request)}")
# Store the upload URL in litellm_params for the transformation method
# Honour the URL already set by transform_create_file_request (e.g. Bedrock pre-signed S3 uploads),
# fall back to api_base for providers that do not set it.
litellm_params_with_url = dict(litellm_params)
litellm_params_with_url["upload_url"] = api_base
if "upload_url" not in litellm_params:
litellm_params_with_url["upload_url"] = api_base
return provider_config.transform_create_file_response(
model=None,