From 411b525a836cf4bb350b9a007ce5584f87be92e0 Mon Sep 17 00:00:00 2001 From: htourinho-clgx Date: Thu, 23 Jul 2026 16:24:37 +0200 Subject: [PATCH] fix(proxy/batches): null-guard await on find_first for sync MagicMock test harnesses --- litellm/proxy/batches_endpoints/endpoints.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/batches_endpoints/endpoints.py b/litellm/proxy/batches_endpoints/endpoints.py index 2fd2e5e5fee..12b1f3cf226 100644 --- a/litellm/proxy/batches_endpoints/endpoints.py +++ b/litellm/proxy/batches_endpoints/endpoints.py @@ -241,14 +241,16 @@ async def create_batch( from litellm.proxy.proxy_server import prisma_client if prisma_client is not None: + import inspect from litellm.repositories.table_repositories import ( ManagedFileRepository, ) - db_file = await ManagedFileRepository(prisma_client).table.find_first( + db_file_res = ManagedFileRepository(prisma_client).table.find_first( where={"unified_file_id": unified_file_id} ) - if db_file is not None and db_file.storage_url: + db_file = await db_file_res if inspect.isawaitable(db_file_res) else db_file_res + if db_file is not None and getattr(db_file, "storage_url", None): _create_batch_data["input_file_id"] = db_file.storage_url response = await llm_router.acreate_batch(**_create_batch_data)