From 4fa577810ba1c6b3258e4242bd662e72b8ea7e8c Mon Sep 17 00:00:00 2001 From: user <70670632+stuxf@users.noreply.github.com> Date: Mon, 4 May 2026 22:43:18 +0000 Subject: [PATCH] fix(container): keep ownership-filter exceptions out of the LLM-error path filter_container_list_response runs after the upstream call has already succeeded; treating an ownership-lookup failure as an LLM-API error fires post_call_failure_hook for a successful upstream call and returns a misleading provider-shaped error to the client. Run the filter outside the try/except so genuine LLM errors stay scoped to the upstream call. --- litellm/proxy/container_endpoints/endpoints.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/container_endpoints/endpoints.py b/litellm/proxy/container_endpoints/endpoints.py index 7e097802632..9650604bf81 100644 --- a/litellm/proxy/container_endpoints/endpoints.py +++ b/litellm/proxy/container_endpoints/endpoints.py @@ -241,11 +241,6 @@ async def list_containers( user_api_base=user_api_base, version=version, ) - return await filter_container_list_response( - response=response, - user_api_key_dict=user_api_key_dict, - custom_llm_provider=custom_llm_provider, - ) except Exception as e: raise await processor._handle_llm_api_exception( e=e, @@ -254,6 +249,16 @@ async def list_containers( version=version, ) + # Ownership filtering runs OUTSIDE the LLM-exception scope: a DB error + # in the ownership lookup is not an LLM-API error and shouldn't be + # translated to a provider-shaped failure (which would also fire the + # post_call_failure_hook for what is in fact a successful upstream call). + return await filter_container_list_response( + response=response, + user_api_key_dict=user_api_key_dict, + custom_llm_provider=custom_llm_provider, + ) + @router.get( "/v1/containers/{container_id}",