fix: convert remaining dict(request.headers) to _safe_get_request_headers

Missed conversions in user_api_key_auth.py and litellm_pre_call_utils.py.
Both call sites are read-only so no .copy() needed.
This commit is contained in:
Ryan Crabbe 2026-02-24 15:21:43 -08:00 • committed by Sameer Kankute
parent 071a7bbad1
commit f778afc14b
2 changed files with 3 additions and 2 deletions

View file

@ -483,7 +483,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
parent_otel_span = (
open_telemetry_logger.create_litellm_proxy_request_started_span(
start_time=start_time,
headers=dict(request.headers),
headers=_safe_get_request_headers(request),
)
)

View file

@ -14,6 +14,7 @@ from litellm.proxy._types import (AddTeamCallback, CommonProxyErrors,
LitellmDataForBackendLLMCall,
LitellmUserRoles, SpecialHeaders,
TeamCallbackMetadata, UserAPIKeyAuth)
from litellm.proxy.common_utils.http_parsing_utils import _safe_get_request_headers
# Cache special headers as a frozenset for O(1) lookup performance
_SPECIAL_HEADERS_CACHE = frozenset(
@ -824,7 +825,7 @@ 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
_raw_headers: Dict[str, str] = dict(request.headers)
_raw_headers: Dict[str, str] = _safe_get_request_headers(request)
_headers: Dict[str, str] = clean_headers(
request.headers,
litellm_key_header_name=(