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
fix(redis): honor ssl value instead of key presence when building async connection pool (#32590)
Yassin Kortam903219a8b10e
diff --git a/litellm/_redis.py b/litellm/_redis.pyindex 0b91cdabffc..fe5c5cdabe9 100644--- a/litellm/_redis.py+++ b/litellm/_redis.py@@ -688,10 +688,8 @@ def get_redis_connection_pool(elif redis_connect_func and hasattr(redis_connect_func, "_gcp_service_account"):redis_kwargs["credential_provider"] = GCPIAMCredentialProvider(redis_connect_func._gcp_service_account)- connection_class = async_redis.Connection- if redis_kwargs.pop("ssl", False):- connection_class = async_redis.SSLConnection- redis_kwargs["connection_class"] = connection_class+ if redis_kwargs.pop("ssl", None):+ redis_kwargs["connection_class"] = async_redis.SSLConnectionreturn async_redis.BlockingConnectionPool(timeout=REDIS_CONNECTION_POOL_TIMEOUT, **redis_kwargs)diff --git a/tests/test_litellm/test_redis.py b/tests/test_litellm/test_redis.pyindex 4b9f13c340b..0818237655d 100644--- a/tests/test_litellm/test_redis.py+++ b/tests/test_litellm/test_redis.py@@ -724,3 +724,16 @@ def test_connection_pool_without_ssl_kwarg_uses_plain_connection(monkeypatch):call_kwargs = mock_pool.call_args.kwargsassert call_kwargs.get("connection_class") is not async_redis.SSLConnectionassert "ssl" not in call_kwargs+++def test_connection_pool_env_redis_ssl_false_uses_plain_connection(monkeypatch):+ """REDIS_SSL=false from the environment must not select SSLConnection."""+ monkeypatch.delenv("REDIS_URL", raising=False)+ monkeypatch.delenv("REDIS_CLUSTER_NODES", raising=False)+ monkeypatch.setenv("REDIS_SSL", "false")++ pool = get_redis_connection_pool(host="plain-host", port=6379)++ assert pool is not None+ assert pool.connection_class is async_redis.Connection+ assert "ssl" not in pool.connection_kwargs