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]

fix(python-bridge): allow instance shadowing only for validated config attributes

Yujong Leed3f2ddba050b
diff --git a/litellm-rust/crates/python-bridge/src/cache/facade.rs b/litellm-rust/crates/python-bridge/src/cache/facade.rs
index d7ec2052dd0..a6395d086cb 100644
--- a/litellm-rust/crates/python-bridge/src/cache/facade.rs
+++ b/litellm-rust/crates/python-bridge/src/cache/facade.rs
@@ -120,7 +120,7 @@ impl ObjectGuard {
if !attributes.get_item(name)?.is(value.bind(py)) {
return Ok(false);
}
- if instance.contains(name)? && value.bind(py).is_callable() {
+ if instance.contains(name)? && !self.config_names.contains(&name.as_str()) {
return Ok(false);
}
}
diff --git a/tests/test_litellm_rust/test_cache.py b/tests/test_litellm_rust/test_cache.py
index e9f4b99a3b7..73a6321011b 100644
--- a/tests/test_litellm_rust/test_cache.py
+++ b/tests/test_litellm_rust/test_cache.py
@@ -820,6 +820,8 @@ def test_redis_semantic_configuration_drift_falls_back_to_python(
assert resolver.resolve().kind == "python_callback"
with rebound(facade.cache, "_index_name", "other-index"):
assert resolver.resolve().kind == "python_callback"
+ with rebound(facade.cache, "CACHE_KEY_FIELD_NAME", "other-field"):
+ assert resolver.resolve().kind == "python_callback"
def patched_embedding(self: object, prompt: str, metadata: object = None) -> list[float]:
return _semantic_embedding(prompt)