From cd322fafbe415cdc4d418d2d0959a3c0085f3976 Mon Sep 17 00:00:00 2001 From: yucheng Date: Sun, 13 Sep 2026 09:40:56 +0000 Subject: [PATCH] refactor(proxy): read ModelResponse off the litellm package in key health CodeQL flags the module-level import of ModelResponse from litellm.types.utils as part of a cyclic import; the isinstance check now goes through the already-imported litellm package like the other proxy hooks do. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../proxy/management_endpoints/key_management_endpoints.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index 019972d68fe..9903ca6a9ed 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -153,7 +153,6 @@ from litellm.types.proxy.management_endpoints.key_management_endpoints import ( from litellm.types.router import Deployment from litellm.types.utils import ( BudgetConfig, - ModelResponse, PersonalUIKeyGenerationConfig, TeamUIKeyGenerationConfig, ) @@ -7205,7 +7204,9 @@ async def test_key_logging( await asyncio.sleep(2) # wait for callbacks to run, callbacks use batching so wait for the flush event callback_log_contents: Final = log_capture_string.getvalue() - health_check_event_id: Final = health_check_response.id if isinstance(health_check_response, ModelResponse) else "" + health_check_event_id: Final = ( + health_check_response.id if isinstance(health_check_response, litellm.ModelResponse) else "" + ) gcs_failure: Final = ( await flush_gcs_and_describe_failures(get_custom_logger_compatible_class("gcs_bucket"), health_check_event_id) if "gcs_bucket" in logging_callbacks