Skip to content

Commit 37ad325

Browse files
fix: resolve batch response file IDs even when status unchanged
The status-unchanged early return in update_batch_in_database was skipping ensure_batch_response_managed_file_ids, leaving raw provider input_file_id (and other raw IDs) in the user-facing response when polling an in-progress batch. Move the in-place file ID normalization above the early return so the response always carries unified managed IDs while still skipping the DB write when nothing changed. Co-authored-by: Yassin Kortam <yassin@berri.ai>
1 parent 525761a commit 37ad325

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

litellm/proxy/openai_files_endpoints/common_utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,18 @@ async def update_batch_in_database(
895895
if not prisma_client:
896896
return
897897

898+
# Always normalize the response's file IDs to unified managed IDs
899+
# (mutates in place) so the caller returns unified IDs to the user
900+
# even when we skip the DB update below for an unchanged status.
901+
await ensure_batch_response_managed_file_ids(
902+
response=response,
903+
managed_files_obj=managed_files_obj,
904+
prisma_client=prisma_client,
905+
verbose_proxy_logger=verbose_proxy_logger,
906+
user_api_key_dict=user_api_key_dict,
907+
db_batch_object=db_batch_object,
908+
)
909+
898910
# Only update if status has changed (when db_batch_object is provided)
899911
if db_batch_object and response.status == db_batch_object.status:
900912
return
@@ -908,15 +920,6 @@ async def update_batch_in_database(
908920
f"Updating batch {batch_id} status to {response.status} after {operation}"
909921
)
910922

911-
await ensure_batch_response_managed_file_ids(
912-
response=response,
913-
managed_files_obj=managed_files_obj,
914-
prisma_client=prisma_client,
915-
verbose_proxy_logger=verbose_proxy_logger,
916-
user_api_key_dict=user_api_key_dict,
917-
db_batch_object=db_batch_object,
918-
)
919-
920923
# Normalize status for database storage
921924
db_status = response.status if response.status != "completed" else "complete"
922925

0 commit comments

Comments
 (0)