fix: prevent duplicate failure callbacks for pass-through endpoints

The sync failure_handler was calling log_failure_event() for CustomLogger
instances on pass-through endpoint failures, while async_failure_handler
also called async_log_failure_event() — causing duplicate Datadog/Arize logs.

Add the same call_type != pass_through guard that already exists in the
success handler. Also pass the existing logging_obj in request_payload so
_handle_logging_proxy_only_error preserves the correct call_type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Harshit28j 2026-03-06 04:27:33 +05:30
parent af8431539e
commit 9cd6b58bc8
2 changed files with 5 additions and 11 deletions

View file

@ -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,

View file

@ -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(