From 52549ea3514fae4bca4df5a5451e518a0d6fbabe Mon Sep 17 00:00:00 2001 From: yucheng-berri <293926326+yucheng-berri@users.noreply.github.com> Date: Sat, 10 Oct 2026 04:15:09 -0700 Subject: [PATCH] fix(logging): keep AttributeError for non-mapping redaction headers The lint-gate retype read a non-mapping headers carrier as empty headers, so should_redact_message_logging returned the global flag where main raised AttributeError. The complexity router reads that error as an undecidable request and withholds the classifier reply, so a request with headers=None logged the raw reply again (test_llm_v2 undecidable-headers-fail-closed). --- litellm/litellm_core_utils/redact_messages.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.py index 9b6eeabc840..37d24a68084 100644 --- a/litellm/litellm_core_utils/redact_messages.py +++ b/litellm/litellm_core_utils/redact_messages.py @@ -500,7 +500,11 @@ def should_redact_message_logging(model_call_details: Mapping) -> bool: ) # Get headers from the metadata - request_headers: Final = _str_keyed_mapping(metadata.get("headers")) + raw_headers: Final = metadata.get("headers", {}) + if not isinstance(raw_headers, Mapping): + # Callers such as the complexity router read AttributeError as an undecidable request and redact + raise AttributeError(f"request headers are {type(raw_headers).__name__}, not a mapping") # noqa: TRY004 # callers catch AttributeError + request_headers: Final = _str_keyed_mapping(raw_headers) # Check for headers that explicitly control redaction if request_headers and bool(request_headers.get("litellm-disable-message-redaction", False)):