Repository navigation
fix(cli): send FT._LIST to the default node on Redis Cluster - #848
Conversation
|
Hi, thanks for your contribution. Please follow the repository's pull request template and |
|
Thanks. I’ll update the PR description to use the template and check whether stacking on #795 is worthwhile. |
|
Thanks. The description now follows the template, and the CLI handles RESP3 set replies. I kept the PR based on |
vishal-bala
left a comment
There was a problem hiding this comment.
Thanks for picking this up, and for the quick turnaround on the description. The diagnosis is right: FT._LIST has no key, so a cluster client can't choose a node for it and raises unless you give it one. I'm requesting changes because I think the fix belongs one layer down, and because that makes the PR much smaller.
Why I'd reuse listall()
#847 suggested listing indexes through SearchIndex.listall(), and #795 has since merged. Its listall() already sends FT._LIST to the default node on a cluster. This PR copies that routing into the CLI, which leaves two copies that have to be fixed together. The Notes say the CLI can't reuse listall() because it has no IndexSchema, but redisvl.migration.utils.list_indexes(redis_url=...) covers exactly that. It builds a placeholder index with no fields and calls listall(), and rvl migrate already uses it. The handler would become:
redis_url = create_redis_url(args)
indices = list_indexes(redis_url=redis_url)That deletes more than it adds, and the CLI gets any later routing fix for free.
The RESP3 branch
I couldn't find a way for index_names to be a set. In redis-py 8.1.0 the RESP3 parser turns ~ (set) replies into lists (_parsers/resp3.py, "we return sets as list, all the time"). I confirmed this by running a set frame through the parser, and RedisVL defaults to protocol 2 anyway. The Redis docs do describe the wire type as a set, which is probably where the branch came from, but redis-py has already converted it by the time the CLI sees it. The tests that return a set from a mock exercise a case a real client doesn't produce. If you have seen a set reach this code, please share the client version and the reply and I'll happily reconsider. I haven't checked redis-py 6.3.x or the hiredis parser, so those are open.
Tests
Only one behaviour needs a test: on a cluster, the CLI asks for the index list with a target node. One test with a MagicMock(spec=RedisCluster) client does that. test_listall_standalone_keeps_plain_ft_list passes without the fix, and the two RESP3 tests only catch a missing sorted() about half the time, depending on hash seed. Details are in the inline comments.
Description and branch
- Please add the AI Assistance section from the PR template.
- Drop the RESP3 and ancestry rationale.
- Say what users see now, for example "
rvl index listallno longer fails against Redis Cluster." - Add the live cluster run to "Not verified".
- The branch is 16 commits behind
main, so it needs a rebase.
I haven't run this against a live cluster either. Cluster tests don't run in PR CI, so the unit test is the check that will run.
`rvl index listall` called `FT._LIST` directly, so it failed on a Redis Cluster: the command has no key, and the client cannot pick a node for it. Delegate to `list_indexes()`, which builds a placeholder index and calls `SearchIndex.listall()`. That method already sends the keyless `FT._LIST` to the default node, so the CLI keeps no copy of the routing. The RESP3 set handling goes with it: redis-py's RESP3 parser returns `~` replies as lists, and RedisVL talks protocol 2.
413e000 to
62051ef
Compare
|
@vishal-bala all six points are in
The description follows the template again: AI Assistance section added, the RESP3 and ancestry rationale removed, Release Notes states the user-visible change, and the live cluster run is under Not verified. The diff against |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #848 +/- ##
==========================================
+ Coverage 79.76% 79.79% +0.02%
==========================================
Files 121 121
Lines 14852 14852
Branches 2599 2599
==========================================
+ Hits 11847 11851 +4
+ Misses 2291 2289 -2
+ Partials 714 712 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Fixes #847.
Motivation
FT._LISThas no key, so on a Redis Cluster the client cannot pick a node for it andrvl index listallfails.SearchIndex.listall()already sends the command to the default node (#795), so the CLI only has to call it instead of running the command itself.Changes
Index.listall()now delegates toredisvl.migration.utils.list_indexes(), the helperrvl migratealready uses: it builds a name-only placeholder index and callsSearchIndex.listall(). The handler keeps the URL built bycreate_redis_url()and drops its own connection handling and reply conversion.tests/unit/test_cli_index.py: one cluster test asserts thatFT._LISTreaches the default node and that the JSON output is unchanged. The patch target in thelistallruntime-error cases moves toredisvl.migration.utils, where the connection is now created.Release Notes
rvl index listallno longer fails against Redis Cluster.AI Assistance
OpenCode (DeepSeek V4.1 Flash): implementation, tests and description. OpenCode (gpt-6.1-sol): review of the final diff. I reviewed the change manually and take responsibility for it.
Reviewer Brief
Start here:
redisvl/cli/index.py:223,Index.listall(). Delegating to the existinglist_indexes()helper makes the CLI useSearchIndex.listall()'s cluster routing while preserving its output formatting.Not verified: a live Redis Cluster run. Cluster tests only run nightly, and no cluster was available here.
Beyond CI: the cluster test fails against
mainand passes on this branch;tests/unit/test_cli_index.py27 passed, the migration unit tests 89 passed, and mypy, black and isort are clean on the changed files.Reviewed
62051ef· OpenCode (gpt-6.1-sol) · lenses: correctness, security, design, tests, docs, Redis behaviour · challenger applied