From 2f958f218729cc986c8bfeecbea85295fb06f109 Mon Sep 17 00:00:00 2001 From: yassin Date: Sun, 30 Aug 2026 00:51:06 +0000 Subject: [PATCH] fix(managed_files): match provider-format ids against model_object_id and flat_model_file_ids Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- enterprise/litellm_enterprise/proxy/hooks/managed_files.py | 4 ++-- .../litellm_enterprise/proxy/hooks/test_managed_files.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py index d5f75783a62..6496fcf2fd9 100644 --- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py +++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py @@ -438,7 +438,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): return managed_object = ( await self.prisma_client.db.litellm_managedobjecttable.find_first( - where={"unified_object_id": object_id} + where={"OR": [{"unified_object_id": object_id}, {"model_object_id": object_id}]} ) ) if managed_object is None: @@ -466,7 +466,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): return managed_file = ( await self.prisma_client.db.litellm_managedfiletable.find_first( - where={"unified_file_id": file_id} + where={"OR": [{"unified_file_id": file_id}, {"flat_model_file_ids": {"has": file_id}}]} ) ) if managed_file is None: diff --git a/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py b/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py index e3025255518..57394f1cebe 100644 --- a/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py +++ b/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py @@ -3227,7 +3227,7 @@ async def test_team_b_cannot_access_team_a_provider_format_batch( assert exc_info.value.status_code == 403 prisma_client.db.litellm_managedobjecttable.find_first.assert_awaited_once_with( - where={"unified_object_id": batch_id} + where={"OR": [{"unified_object_id": batch_id}, {"model_object_id": batch_id}]} ) @@ -3360,7 +3360,7 @@ async def test_team_b_cannot_access_team_a_provider_format_file( assert exc_info.value.status_code == 403 prisma_client.db.litellm_managedfiletable.find_first.assert_awaited_once_with( - where={"unified_file_id": file_id} + where={"OR": [{"unified_file_id": file_id}, {"flat_model_file_ids": {"has": file_id}}]} )