From d3f2ddba050bad5af5ec662ac83bac263919d907 Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Mon, 21 Sep 2026 20:58:02 +0000 Subject: [PATCH] fix(python-bridge): allow instance shadowing only for validated config attributes Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm-rust/crates/python-bridge/src/cache/facade.rs | 2 +- tests/test_litellm_rust/test_cache.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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)