Skip to content

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]

eliminates recursion for an explicit stack

Achintya Rajandceaf2f0f124
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 7feb4b825b4..57988f8d995 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -2890,14 +2890,17 @@ class ProxyConfig:
Deep-merge src into dst, skipping None values from src.
On conflicts, src (DB) wins.
"""
- for k, v in src.items():
- if v is None:
- # Preserve existing config when DB value is None (matches prior behavior)
- continue
- if isinstance(v, dict) and isinstance(dst.get(k), dict):
- _deep_merge_dicts(dst[k], v)
- else:
- dst[k] = v
+ stack = [(dst, src)]
+ while stack:
+ d, s = stack.pop()
+ for k, v in s.items():
+ if v is None:
+ # Preserve existing config when DB value is None (matches prior behavior)
+ continue
+ if isinstance(v, dict) and isinstance(d.get(k), dict):
+ stack.append((d[k], v))
+ else:
+ d[k] = v
if param_name == "environment_variables":
decrypted_env_vars = self._decrypt_and_set_db_env_variables(db_param_value)