diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 6f2d8f531b5..6fa279dcbf5 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -2922,8 +2922,7 @@ class Logging(LiteLLMLoggingBaseClass): if ( isinstance(callback, CustomLogger) and is_sync_request - and self.call_type - != CallTypes.pass_through.value # pass-through endpoints call async_log_failure_event + and (self.call_type != CallTypes.pass_through.value) # pass-through endpoints call async_log_failure_event ): # 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 c3102e36e3e..5b4166d0979 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -646,6 +646,7 @@ async def pass_through_request( # noqa: PLR0915 _parsed_body: Optional[dict] = None # kwargs for pass through endpoint, contains metadata, litellm_params, call_type, litellm_call_id, passthrough_logging_payload kwargs: Optional[dict] = None + logging_obj: Optional[Logging] = None ######################################################### try: @@ -959,10 +960,8 @@ async def pass_through_request( # noqa: PLR0915 # Pass the existing logging_obj so _handle_logging_proxy_only_error # uses it (preserves call_type="pass_through_endpoint" for dedup) - try: + if logging_obj is not None: request_payload["litellm_logging_obj"] = logging_obj - except NameError: - pass await proxy_logging_obj.post_call_failure_hook( user_api_key_dict=user_api_key_dict, @@ -1705,10 +1704,8 @@ async def websocket_passthrough_request( # noqa: PLR0915 request_payload[key] = value # Pass the existing logging_obj (preserves call_type for dedup) - try: + if logging_obj is not None: request_payload["litellm_logging_obj"] = logging_obj - except NameError: - pass # Log the connection failure using the same pattern as HTTP await proxy_logging_obj.post_call_failure_hook( @@ -1737,10 +1734,8 @@ async def websocket_passthrough_request( # noqa: PLR0915 request_payload[key] = value # Pass the existing logging_obj (preserves call_type for dedup) - try: + if logging_obj is not None: request_payload["litellm_logging_obj"] = logging_obj - except NameError: - pass # Log the unexpected error using the same pattern as HTTP await proxy_logging_obj.post_call_failure_hook(