fix(redis): honor ssl value instead of key presence when building async connection pool (#32590)

* fix(redis): honor ssl value instead of key presence when building async connection pool

* ci: rerun codspeed after cross-runtime-environment flake
This commit is contained in:
Yassin Kortam 2026-07-16 13:38:01 -07:00 • committed by GitHub
parent c6778b79c3
commit 903219a8b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View file

@ -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.SSLConnection
return async_redis.BlockingConnectionPool(timeout=REDIS_CONNECTION_POOL_TIMEOUT, **redis_kwargs)

View file

@ -724,3 +724,16 @@ def test_connection_pool_without_ssl_kwarg_uses_plain_connection(monkeypatch):
call_kwargs = mock_pool.call_args.kwargs
assert call_kwargs.get("connection_class") is not async_redis.SSLConnection
assert "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