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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): reset filtered container pagination
user9376b30bca95
diff --git a/litellm/proxy/container_endpoints/ownership.py b/litellm/proxy/container_endpoints/ownership.pyindex e3d8da8b0de..2260d67b629 100644--- a/litellm/proxy/container_endpoints/ownership.py+++ b/litellm/proxy/container_endpoints/ownership.py@@ -219,11 +219,14 @@ def _set_container_list_data(response: Any, data: List[Any]) -> Any:else:response["first_id"] = Noneresponse["last_id"] = None+ response["has_more"] = Falsereturn responseresponse.data = dataresponse.first_id = _get_response_id(data[0]) if data else Noneresponse.last_id = _get_response_id(data[-1]) if data else None+ if not data and hasattr(response, "has_more"):+ response.has_more = Falsereturn responsediff --git a/tests/test_litellm/containers/test_container_proxy_ownership.py b/tests/test_litellm/containers/test_container_proxy_ownership.pyindex d0b755645da..40397a18860 100644--- a/tests/test_litellm/containers/test_container_proxy_ownership.py+++ b/tests/test_litellm/containers/test_container_proxy_ownership.py@@ -233,6 +233,76 @@ async def test_should_filter_container_list_to_owned_records(monkeypatch):assert where["created_by"]["in"] == ["user-1", "user:user-1"]+async def test_should_clear_has_more_when_filtered_container_list_is_empty(+ monkeypatch,+):+ table = AsyncMock()+ table.find_many.return_value = [+ SimpleNamespace(model_object_id="container:openai:cntr_owned"),+ ]+ prisma_client = SimpleNamespace(+ db=SimpleNamespace(litellm_managedobjecttable=table)+ )+ monkeypatch.setattr(+ ownership,+ "_get_prisma_client",+ AsyncMock(return_value=prisma_client),+ )+ auth = UserAPIKeyAuth(user_id="user-1")+ response = ContainerListResponse(+ object="list",+ data=[_container("cntr_other")],+ has_more=True,+ )++ filtered = await ownership.filter_container_list_response(+ response=response,+ user_api_key_dict=auth,+ custom_llm_provider="openai",+ )++ assert filtered.data == []+ assert filtered.first_id is None+ assert filtered.last_id is None+ assert filtered.has_more is False+++async def test_should_clear_dict_has_more_when_filtered_container_list_is_empty(+ monkeypatch,+):+ table = AsyncMock()+ table.find_many.return_value = [+ SimpleNamespace(model_object_id="container:openai:cntr_owned"),+ ]+ prisma_client = SimpleNamespace(+ db=SimpleNamespace(litellm_managedobjecttable=table)+ )+ monkeypatch.setattr(+ ownership,+ "_get_prisma_client",+ AsyncMock(return_value=prisma_client),+ )+ auth = UserAPIKeyAuth(user_id="user-1")+ response = {+ "object": "list",+ "data": [{"id": "cntr_other"}],+ "has_more": True,+ }++ filtered = await ownership.filter_container_list_response(+ response=response,+ user_api_key_dict=auth,+ custom_llm_provider="openai",+ )++ assert filtered["data"] == []+ assert filtered["first_id"] is None+ assert filtered["last_id"] is None+ assert filtered["has_more"] is False++@pytest.mark.asyncioasync def test_should_filter_container_list_with_in_memory_ownership(monkeypatch):monkeypatch.setattr(