Repository navigation
fix(connection): strip the cluster parameter for sync standalone clients - #867
Merged
Merged
Conversation
get_redis_connection passed cluster=False, or ?cluster=false in the URL, straight to Redis.from_url, so the first command raised TypeError. The async factory already strips it. Strip it on the sync standalone path too, and make the helper remove only the cluster parameter: rebuilding the URL with urlunparse turned unix:///path into unix:/path, which the sync client rejects.
vishal-bala
requested changes
Nov 24, 2026
Splitting the URL at '?' pulled the fragment into the query, so for redis://h/0?cluster=false#local&db=1 the helper kept db=1 as a connection option and the client selected database 1. Split off the fragment first and reattach it unchanged.
vishal-bala
self-requested a review
November 25, 2026 09:22
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #867 +/- ##
==========================================
+ Coverage 80.17% 80.38% +0.21%
==========================================
Files 121 121
Lines 14864 14906 +42
Branches 2601 2614 +13
==========================================
+ Hits 11917 11982 +65
+ Misses 2226 2222 -4
+ Partials 721 702 -19
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
vishal-bala
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #866.
RedisConnectionFactory.get_redis_connectionpassedcluster=False, or?cluster=falsein the URL, straight toRedis.from_urlfor a standalone server, so the first command raisedTypeError: AbstractConnection.__init__() got an unexpected keyword argument 'cluster'.SearchIndexbuilt withredis_urlandconnection_kwargs={"cluster": False}failed the same way. The async factory has stripped the parameter since #346.Changes
Strip
clusteron the sync standalone pathThe standalone branch of
get_redis_connectionnow passes the URL and kwargs through_strip_cluster_from_url_and_kwargsbeforeRedis.from_url, as_get_aredis_connectionalready does. The sync cluster branch is unchanged, becauseRedisClusterdropsclusteritself.Remove only the
clusterparameter from the URL_strip_cluster_from_url_and_kwargsused to parse the URL and rebuild it withurlunparse. That turnsunix:///tmp/redis.sockintounix:/tmp/redis.sock, which the sync client rejects withValueError. Now that every sync standalone URL goes through the helper, it filters the query string instead. It returns the URL unchanged when there is noclusterparameter, and otherwise drops only theclusterparameters, decoding each key asparse_qsdoes.Notes
The migration helpers that call
Redis.from_url(redis_url)directly (redisvl/migration/planner.py:473,redisvl/migration/async_planner.py:198,redisvl/migration/quantize.py:435) are left out. They bypass the connection factory for every URL form, including cluster and sentinel URLs, so they're a separate change.Release Notes
RedisConnectionFactory.get_redis_connection, andSearchIndexwith aredis_url, now acceptcluster=Falseor?cluster=falsefor a standalone server, as the async factory already did. Before, the first command raisedTypeError.AI Assistance
Claude Code (claude-opus-5-5): investigation, implementation, tests and description.
Reviewer Brief
Start here:
_strip_cluster_from_url_and_kwargsinredisvl/redis/connection.py:114. Every sync standalone URL now goes through it, so whatever it changes in a URL reaches every sync user.Where it could fail
redisvl/redis/connection.py:132-142: the query is filtered as a string, after the fragment is split off. A URL without aclusterkey must come back unchanged. With one, the other parameters must reach redis-py with the same values, and nothing in the fragment may become a parameter.Not verified: a live unix socket server; the unix cases were checked through the connection class, path and db that redis-py parses, not by connecting. Python versions other than 3.12.
Beyond CI:
1d7074b. The fourth, the fragment case, passes there and fails on1a4b519.1d7074band on this branch, on redis-py 6.3.0, 7.1.0, 7.4.1 and 8.1.0. The async clients received identical connection kwargs. The sync clients differed only byclusterno longer being passed, in the 11 cases that used to raiseTypeError.&orcluster=inside a fragment, gave the async client identical connection kwargs on redis-py 8.1.0.CLIENT INFOshowed both factories selecting db 0 forredis://…/0?cluster=false#local&db=1, as the async factory did on1d7074b. The sync factory andSearchIndexwithcluster=Falseor?cluster=falseraisedTypeErroron1d7074b, and connect, load and query on this branch.requires_clustertests, which CI runs only nightly, passed against a local six-node Redis 8.4 cluster on redis-py 8.1.0, 7.4.1 and 6.4.0. In some runs, 3 tests failed with "0 of 16384 slots covered" while the cluster was still forming, the same 3 on1d7074band on this branch.Since the last brief:
f9f71fasplits off the URL fragment before filtering the query and reattaches it unchanged.Reviewed
f9f71fa· Claude Code (claude-opus-5-5) · lenses: correctness, security, design, tests, docsNote
Medium Risk
Touches core connection URL parsing for every sync standalone client; incorrect query/fragment handling could misroute DB or break unix URLs, though scope is limited to stripping one parameter.
Overview
Sync standalone connections now run URLs and kwargs through
_strip_cluster_from_url_and_kwargsbeforeRedis.from_url, matching async behavior socluster=Falseor?cluster=falseno longer reaches redis-py and trigger aTypeError.The URL helper no longer rebuilds URLs with
urlunparse. It strips onlyclusterquery keys (withunquote_plus-style key decoding), leaves fragments untouched, and avoids corruptingunix:///paths. Unit tests cover unix sockets, fragments, preserved query params, and the sync factory path.Reviewed by Cursor Bugbot for commit f9f71fa. Bugbot is set up for automated code reviews on this repo. Configure here.