From 583bdb279b36a6ad1dc1113b2ea63cc0f4c05380 Mon Sep 17 00:00:00 2001 From: michelligabriele Date: Fri, 13 Mar 2026 04:53:50 +0100 Subject: [PATCH] address greptile review: move early return before pre_call, trim comments --- litellm/litellm_core_utils/litellm_logging.py | 2 +- .../pass_through_endpoints.py | 2 -- litellm/proxy/utils.py | 13 +++++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 24fcbde1a0b..d091a263df7 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -2923,7 +2923,7 @@ class Logging(LiteLLMLoggingBaseClass): isinstance(callback, CustomLogger) and is_sync_request and self.call_type - != CallTypes.pass_through.value # pass-through endpoints call async_log_failure_event + != CallTypes.pass_through.value ): # custom logger class callback.log_failure_event( start_time=start_time, diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 871d9848aba..0aa99685209 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -961,8 +961,6 @@ async def pass_through_request( # noqa: PLR0915 if kwargs: for key, value in kwargs.items(): request_payload[key] = value - # Ensure the original logging_obj is in request_payload so - # _handle_logging_proxy_only_error reuses it (preserving call_type) if logging_obj is not None: request_payload["litellm_logging_obj"] = logging_obj diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 695f75b86e9..b0d709abbb6 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -1877,19 +1877,16 @@ class ProxyLogging: litellm_logging_obj.model_call_details["input"] = input if litellm_logging_obj.call_type != CallTypes.pass_through.value: litellm_logging_obj.call_type = CallTypes.aembedding.value + # Pass-through endpoints are logged via the callback loop's + # async_post_call_failure_hook — skip pre_call and failure handlers. + if litellm_logging_obj.call_type == CallTypes.pass_through.value: + return + litellm_logging_obj.pre_call( input=input, api_key="", ) - # For pass-through endpoints, skip async_failure_handler and - # failure_handler here. The callback loop in post_call_failure_hook - # will call async_post_call_failure_hook on each CustomLogger, - # which handles logging. Firing both paths would produce duplicate - # entries in Datadog, Arize, and other callback integrations. - if litellm_logging_obj.call_type == CallTypes.pass_through.value: - return - # log the custom exception await litellm_logging_obj.async_failure_handler( exception=original_exception,