mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
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:
parent
5926104f61
commit
37d1577c03
1 changed files with 2 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue