diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index 3168bcd812f..92bf035a986 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -839,9 +839,14 @@ async def add_litellm_data_to_request( # noqa: PLR0915 """ from litellm.proxy.proxy_server import llm_router, premium_user - from litellm.types.proxy.litellm_pre_call_utils import SecretFields + from litellm.types.proxy.litellm_pre_call_utils import ( + RedactedDict, + SecretFields, + ) - _raw_headers: Dict[str, str] = _safe_get_request_headers(request) + _raw_headers: Dict[str, str] = RedactedDict( + _safe_get_request_headers(request) + ) forward_llm_auth = False if general_settings: @@ -938,9 +943,7 @@ async def add_litellm_data_to_request( # noqa: PLR0915 add_provider_specific_headers_to_request(data=data, headers=_headers) ## Cache Controls - headers = request.headers - verbose_proxy_logger.debug("Request Headers: %s", headers) - cache_control_header = headers.get("Cache-Control", None) + cache_control_header = _headers.get("Cache-Control", None) if cache_control_header: cache_dict = parse_cache_control(cache_control_header) data["ttl"] = cache_dict.get("s-maxage") diff --git a/litellm/types/proxy/litellm_pre_call_utils.py b/litellm/types/proxy/litellm_pre_call_utils.py index a956f92187c..95f0107bf65 100644 --- a/litellm/types/proxy/litellm_pre_call_utils.py +++ b/litellm/types/proxy/litellm_pre_call_utils.py @@ -1,6 +1,16 @@ from typing_extensions import TypedDict +class RedactedDict(dict): + """Dict subclass with redacted str/repr to prevent leaking in logs.""" + + def __repr__(self) -> str: + return "RedactedDict(REDACTED)" + + def __str__(self) -> str: + return "RedactedDict(REDACTED)" + + class SecretFields(TypedDict): """ Stored in data["secret_fields"]