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]

Merge remote-tracking branch 'origin/litellm_internal_staging' into devin_ai_fix_file_list_cursor_leak_36087

mateo-berri508e0dbb35c0
diff --cc enterprise/litellm_enterprise/proxy/hooks/managed_files.py
index 851e202e2fb,a3994dccfd6..a6ba1e0a791
--- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
+++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
@@@ -1265,36 -1284,17 +1284,32 @@@ class _PROXY_LiteLLMManagedFiles(Custom
file_object.id
for file_object in cast(List[FileObject], response.data) # type: ignore
]
- user_created_file_ids = await self.get_user_created_file_ids(
- user_api_key_dict, file_ids
- )
+ user_created_file_ids = await self.get_user_created_file_ids(user_api_key_dict, file_ids)
## Filter the response to only include the files created by the user
response.data = user_created_file_ids # type: ignore
+ self._scope_list_page_cursors(response, user_created_file_ids)
return response
return response
return response
+ @staticmethod
+ def _scope_list_page_cursors(response: AsyncCursorPage, data: List[OpenAIFileObject]) -> None:
+ """Rebuild ``first_id`` / ``last_id`` from the caller-scoped page.
+
+ The upstream cursors point at rows that were just filtered out, so
+ leaving them in place discloses other callers' file ids.
+ """
+ if hasattr(response, "first_id"):
+ response.first_id = data[0].id if data else None
+ if hasattr(response, "last_id"):
+ response.last_id = data[-1].id if data else None
+ if not data and hasattr(response, "has_more"):
+ response.has_more = False
+
async def afile_retrieve(
- self, file_id: str, litellm_parent_otel_span: Optional[Span], llm_router=None
+ self, file_id: str, litellm_parent_otel_span: Optional[Span], llm_router: Optional[Router] = None
) -> OpenAIFileObject:
- stored_file_object = await self.get_unified_file_id(
- file_id, litellm_parent_otel_span
- )
+ stored_file_object = await self.get_unified_file_id(file_id, litellm_parent_otel_span)
# Case 1 : This is not a managed file
if not stored_file_object: