Repository navigation
fix: recognize Valkey Search's missing-index error in exists() - #775
Closed
sarankumar1325 wants to merge 1 commit into
Closed
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
Valkey Search answers FT.INFO for an absent index with "Index with name '<name>' not found in database <n>", which matched none of the known wordings, so exists() raised instead of returning False and create() never created the index. Fixes redis#773
Collaborator
|
Hi, thanks for the PR! Support for Valkey Search isn't actually a goal for this project - it's focused on enabling users to build on Redis. Adding support for all of the various forks of Redis would end up bloating the project. I'm going to close this PR as out of scope, but we appreciate you taking the time to put this together. |
6 of 18 tasks
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 #773.
Since #672,
exists()decides that an index is missing by matching theFT.INFOerror against_MISSING_INDEX_ERROR_FRAGMENTS. Valkey Search (for example Amazon ElastiCache for Valkey 9.1) words that error asIndex with name '<name>' not found in database <n>, which matches none of the fragments ("index not found"doesn't match because the name sits between "Index" and "not found"). So on Valkey,exists()raisesRedisSearchErrorinstead of returningFalse, andcreate()(which callsexists()first) never creates the index. That breaks, for example,langgraph-checkpoint-redissetup on a fresh Valkey database.Changes
redisvl/exceptions.py: add"not found in database"to_MISSING_INDEX_ERROR_FRAGMENTS, with a comment naming the Valkey Search wording. Matching still reads the underlying Redis error (__cause__), so the existing protection against an index named after a wording is unchanged.tests/unit/test_index_exists.py: add the Valkey wording toMISSING_INDEX_MESSAGES, sotest_missing_index_wording_returns_falsecovers it (fails onmain, passes with the change).docs/api/exceptions.rst: list the Valkey Search wording alongside the Redis ones.I went with the smaller of the two fixes suggested in the issue (adding the wording) rather than an
FT._LISTfallback, since it keeps #672's least-privilege behaviour and the existing "match known wordings, re-raise everything else" design.Review record
NON_MISSING_INDEX_ERRORS), tests, docs.uv run pytest tests/unit/test_index_exists.py: 14 passed.uv run pytest tests/unit --ignore=tests/unit/test_mcp: same result with and without this change apart from the new case (local failures/errors intest_google_genai_vectorizer.py,test_cli_*, andtest_repr.pycome from my environment, e.g. missing optional deps, and also happen onmain).black --check,isort --check,mypy redisvl/exceptions.py: clean.Note
Low Risk
Narrow addition to known missing-index message fragments with existing tests and docs; non-missing errors remain re-raised.
Overview
Fixes Valkey Search so
SearchIndex.exists()treats Valkey’s missing-indexFT.INFOreply as “not present” instead of raisingRedisSearchError.Valkey reports absences as
Index with name '<name>' not found in database <n>, which did not match the existing Redis-only message fragments (the index name sits between “Index” and “not found”), soexists()failed andcreate()could not run on a fresh Valkey DB.The PR adds the fragment
"not found in database"to_MISSING_INDEX_ERROR_FRAGMENTS(still matched on__cause__so permission/connection errors are unchanged), extends unit tests with the Valkey wording, and documents it indocs/api/exceptions.rst.Reviewed by Cursor Bugbot for commit a7394f6. Bugbot is set up for automated code reviews on this repo. Configure here.