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.
This commit is contained in:
Deepanshu 2026-08-25 21:15:13 -04:00
parent 5926104f61
commit 37d1577c03

View file

@ -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()