From ba8459fda008f7938c169735cd2c126e668ffda0 Mon Sep 17 00:00:00 2001 From: tombii Date: Tue, 3 Mar 2026 22:24:16 +0100 Subject: [PATCH] fix(proxy): add None guard to guardrail branch of streaming iterator hook Apply the same None guard to the apply_guardrail branch for consistency, as flagged in PR review. All three callback dispatch branches now guard against None returns to prevent streaming chain breakage. Co-Authored-By: Claude Sonnet 4.6 --- litellm/proxy/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 091214d78ab..f791603cbd7 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -2122,13 +2122,15 @@ class ProxyLogging: current_response = _new_response elif "apply_guardrail" in type(_callback).__dict__: request_data["guardrail_to_apply"] = callback - current_response = ( + _new_response = ( unified_guardrail.async_post_call_streaming_iterator_hook( user_api_key_dict=user_api_key_dict, request_data=request_data, response=current_response, ) ) + if _new_response is not None: + current_response = _new_response else: _new_response = ( _callback.async_post_call_streaming_iterator_hook(