From 37d1577c030a0cbe47194beaecc2e5c838338061 Mon Sep 17 00:00:00 2001 From: Deepanshu Date: Tue, 25 Aug 2026 21:15:13 -0400 Subject: [PATCH] fix(logging): use MappingProxyType for the failure-hook's sanitized request_data A LIT002 budget check (surfaced by rebasing onto a moved base) flagged the dict comprehension building safe_request_data as mutable construction. MappingProxyType is also a strictly better fit here: a genuinely read-only view, not just an immutable-looking dict, matching the intent that callbacks should never be able to mutate what they're handed. --- litellm/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index c4f5c682009..802dc151428 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -35,6 +35,7 @@ from importlib import resources from inspect import iscoroutine from io import StringIO from os.path import abspath, dirname, join +from types import MappingProxyType import dotenv import httpx @@ -1320,7 +1321,7 @@ async def async_post_call_failure_deployment_hook( _raw_fallback_depth: Final = request_data.get("fallback_depth") fallback_depth: Final = _raw_fallback_depth if isinstance(_raw_fallback_depth, int) else None - safe_request_data: Final = {k: v for k, v in request_data.items() if k != "attempted_targets"} + safe_request_data: Final = MappingProxyType({k: v for k, v in request_data.items() if k != "attempted_targets"}) safe_exception: Final = _snapshot_exception_for_hook(exception) CustomLogger: Final = _get_cached_custom_logger()