Skip to content

Commit 308c906

Browse files
committed
fix(redis): drop a connect func the async cluster client cannot accept
1 parent 2417613 commit 308c906

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

litellm/_redis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ def get_redis_async_client(
648648
for item in redis_kwargs["startup_nodes"]:
649649
new_startup_nodes.append(ClusterNode(**item))
650650
cluster_kwargs.pop("startup_nodes", None)
651+
cluster_kwargs.pop("redis_connect_func", None)
651652

652653
# Default to a periodic health check + TCP keepalive so a connection silently dropped
653654
# by a cluster restart (e.g. ElastiCache Serverless maintenance) is revalidated and

tests/test_litellm/test_redis.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,3 +1005,22 @@ async def connect(connection):
10051005

10061006
assert pool.connection_kwargs["redis_connect_func"] is connect
10071007
assert "credential_provider" not in pool.connection_kwargs
1008+
1009+
1010+
def test_async_cluster_drops_a_connect_func_it_cannot_pass_on():
1011+
"""redis-py's async RedisCluster has no redis_connect_func parameter, so a connect func that
1012+
is not translated into a credential provider has to be dropped rather than forwarded.
1013+
"""
1014+
1015+
async def connect(connection):
1016+
return None
1017+
1018+
redis_kwargs = {
1019+
"startup_nodes": [{"host": "cluster-node", "port": 6379}],
1020+
"redis_connect_func": connect,
1021+
}
1022+
1023+
with patch("litellm._redis._get_redis_client_logic", return_value=redis_kwargs):
1024+
client = get_redis_async_client()
1025+
1026+
assert isinstance(client, async_redis.RedisCluster)

0 commit comments

Comments
 (0)