fix(redis): only use SSLConnection when ssl is truthy in connection pool kwargs - #32825
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes a one-character logic bug in
Confidence Score: 5/5Safe to merge — the change is a single-line targeted fix with no effect on callers that omit The fix is minimal and correctly scoped: switching from a key-presence check to a value-truthiness check restores the intended behavior without touching any other code path. The No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/_redis.py | Fixes the SSL selection logic: changed presence check "ssl" in redis_kwargs to a truthiness check via redis_kwargs.pop("ssl", False), so falsy ssl values no longer incorrectly enable TLS. |
| tests/test_litellm/test_redis.py | Adds three new mock-only unit tests covering all falsy ssl variants (False, None, 0, ""), ssl=True, and the omit-ssl case; no real network calls are made. |
Reviews (1): Last reviewed commit: "fix(redis): only use SSLConnection when ..." | Re-trigger Greptile
f68f7a1 to
195c898
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 195c898. Configure here.
195c898 to
1881083
Compare
Relevant issues
Fixes the coordination Redis connection test and save flow added in #32661; without this, every request the new admin UI form sends against a non-TLS Redis fails
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Live proxy on localhost:4000 (dev_config with a plaintext Redis on 6379). Before the fix, the exact payload the coordination Redis UI sends (it always includes an explicit
sslboolean) times out:After the fix, the same request succeeds, and
ssl: truestill attempts TLS and correctly reports the plaintext server as unreachable:UI check: on http://localhost:3000/caching, Coordination Redis tab, Test Connection with host 127.0.0.1, port 6379 and the SSL toggle off now shows the success toast instead of "Connection test failed: Connection timed out after 5.0s"
Type
🐛 Bug Fix
Changes
get_redis_connection_poolinlitellm/_redis.pychoseSSLConnectionwhenever thesslkey was present in the kwargs, regardless of its value, sossl: falseenabled TLS. The check dates to the originalREDIS_SSLsupport (d1217b9), where the key was only ever set when the env var was literally "true", so presence and truth were the same thing back then. The coordination Redis UI from #32661 is the first caller that always sends an explicitsslboolean, which makes the presence check select TLS against plaintext servers; the handshake hangs until the 5s ping timeout and every connection test and save from the UI failsThe fix switches the check to the value:
if redis_kwargs.pop("ssl", False):. The pop is unconditional so a falsysslnever leaks intoBlockingConnectionPoolkwargs, which plainConnectionwould reject.ssl: truebehavior is unchangedRegression tests in
tests/test_litellm/test_redis.pyassert that each falsy form (False,None,0,"") yields a plain connection, thatssl=Truestill selectsSSLConnection, and that omittingsslkeeps the plain default. With the fix reverted, exactly the four falsy cases failNote
Low Risk
Small, localized change to connection-pool construction with explicit regression tests;
ssl=Truebehavior is unchanged.Overview
get_redis_connection_poolno longer treats any presentsslkey as “use TLS.” It now usesredis_kwargs.pop("ssl", False)so only a truthysslselectsasync_redis.SSLConnection; falsy values (false,null,0,"") keep a plain connection andsslis removed so it is not passed through toBlockingConnectionPool.This fixes coordination Redis test/save from the admin UI, which always sends an explicit
sslboolean—previouslyssl: falsestill opened TLS and timed out against plaintext Redis.Regression tests cover falsy
ssl,ssl=True, and omittingssl.Reviewed by Cursor Bugbot for commit 195c898. Bugbot is set up for automated code reviews on this repo. Configure here.