Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Address review feedback: remove dead code, add error handling, strengthen test assertions

Ryan Crabbec4db53a98a65
diff --git a/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py b/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
index d4ab1d881d9..10f7f98b719 100644
--- a/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
+++ b/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
@@ -78,8 +78,6 @@ class CheckBatchCost:
"status": {"not_in": ["failed", "expired", "cancelled"]}
}
)
- completed_jobs = []
-
for job in jobs:
# get the model from the job
unified_object_id = job.unified_object_id
@@ -237,13 +235,16 @@ class CheckBatchCost:
)
# mark the job as complete
- completed_jobs.append(job)
-
- await self.prisma_client.db.litellm_managedobjecttable.update(
- where={"id": job.id},
- data={
- "batch_processed": True,
- "status": "complete",
- "file_object": response.model_dump_json(),
- },
- )
+ try:
+ await self.prisma_client.db.litellm_managedobjecttable.update(
+ where={"id": job.id},
+ data={
+ "batch_processed": True,
+ "status": "complete",
+ "file_object": response.model_dump_json(),
+ },
+ )
+ except Exception as db_err:
+ verbose_proxy_logger.error(
+ f"CheckBatchCost: failed to mark job {job.id} complete in DB: {db_err}"
+ )
diff --git a/tests/test_litellm/enterprise/proxy/test_managed_files_access_check.py b/tests/test_litellm/enterprise/proxy/test_managed_files_access_check.py
index 7b7643aeec5..8cb642b7a44 100644
--- a/tests/test_litellm/enterprise/proxy/test_managed_files_access_check.py
+++ b/tests/test_litellm/enterprise/proxy/test_managed_files_access_check.py
@@ -198,3 +198,12 @@ async def test_check_batch_cost_should_call_afile_content_directly_with_credenti
# managed_files_obj.afile_content should NOT have been called
mock_managed_files_hook.afile_content.assert_not_called()
+
+ # Verify the DB update writes batch_processed, status, and file_object
+ mock_prisma.db.litellm_managedobjecttable.update.assert_called_once()
+ update_call_kwargs = mock_prisma.db.litellm_managedobjecttable.update.call_args.kwargs
+ assert update_call_kwargs["data"]["batch_processed"] is True
+ assert update_call_kwargs["data"]["status"] == "complete"
+ assert "file_object" in update_call_kwargs["data"], (
+ "file_object must be written to DB so list_batches reads updated status"
+ )