The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Bound _get_masked_values recursion depth
Yuneng Jiange7f4e77af091
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex 70da405eef1..fe5b75359b9 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -3517,6 +3517,8 @@ def _get_masked_values(mask_all_values: bool = False,unmasked_length: int = 4,number_of_asterisks: Optional[int] = 4,+ _depth: int = 0,+ _max_depth: int = 20,) -> dict:"""Internal debugging helper function@@ -3540,12 +3542,16 @@ def _get_masked_values(def _mask_value(v: Any) -> Any:if isinstance(v, dict):+ if _depth >= _max_depth:+ return vreturn _get_masked_values(v,ignore_sensitive_values=ignore_sensitive_values,mask_all_values=mask_all_values,unmasked_length=unmasked_length,number_of_asterisks=number_of_asterisks,+ _depth=_depth + 1,+ _max_depth=_max_depth,)if not isinstance(v, str):return vdiff --git a/tests/code_coverage_tests/recursive_detector.py b/tests/code_coverage_tests/recursive_detector.pyindex 99b5125b198..fc9c99f6afc 100644--- a/tests/code_coverage_tests/recursive_detector.py+++ b/tests/code_coverage_tests/recursive_detector.py@@ -45,6 +45,7 @@ IGNORE_FUNCTIONS = ["_convert_to_json_serializable_dict", # max depth set (default 20) and circular reference protection to prevent infinite recursion."dict", # max depth set. _LiteLLMParamsDictView.dict() calls builtin dict(), not itself."_read_image_bytes", # max depth set.+ "_get_masked_values", # max depth set (default 20) to prevent infinite recursion while masking nested sensitive config dicts.]