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]

fix(proxy): report has_more false on caller-scoped file list pages

mateo-berri82662dc104db
diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
index a6ba1e0a791..37d267fcd6e 100644
--- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
+++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
@@ -1297,13 +1297,15 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
"""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.
+ leaving them in place discloses other callers' file ids. ``has_more``
+ is always cleared because ``after`` is never forwarded upstream, so
+ no further page is reachable through the proxy.
"""
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"):
+ if hasattr(response, "has_more"):
response.has_more = False
async def afile_retrieve(
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 d3efcf2e7a0..fde1feb80e2 100644
--- a/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py
+++ b/tests/enterprise/litellm_enterprise/proxy/hooks/test_managed_files.py
@@ -3112,7 +3112,7 @@ async def test_file_list_cursors_follow_the_owner_scoped_page():
upstream_page = AsyncCursorPage[FileObject].construct(
data=[_raw_file("file-someone-else"), _raw_file("file-mine")],
- has_more=False,
+ has_more=True,
first_id="file-someone-else",
last_id="file-mine",
object="list",
@@ -3146,3 +3146,4 @@ async def test_file_list_cursors_follow_the_owner_scoped_page():
assert [file_object.id for file_object in response.data] == ["litellm_proxy:mine"]
assert response.first_id == "litellm_proxy:mine"
assert response.last_id == "litellm_proxy:mine"
+ assert response.has_more is False