RI-8316 Match key type when finding indexes for a key#6200
Open
dantovska wants to merge 1 commit into
Open
Conversation
The key-indexes endpoint matched indexes by prefix only, so a JSON key matched FT.CREATE ... ON HASH indexes with the same prefix and the key details panel wrongly offered "View index". Resolve the key's type via TYPE and require it to match the index definition's key_type; keys of unsearchable types return no indexes. Fixes #RI-8316 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Code Coverage - Backend unit tests
Test suite run success3660 tests passing in 319 suites. Report generated by 🧪jest coverage report action from 48eaa9d |
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.
What
The
redisearch/key-indexesendpoint (behind "View index" / "Make searchable" in the key details panel) matched indexes by prefix only — the index definition'skey_typewas returned but never compared. A JSON key likefoo:bartherefore matched anFT.CREATE … ON HASH PREFIX 1 "foo:"index and the panel showed "View index" for an index that will never cover that key.The service now resolves the key's type with
TYPEand only returns indexes whosekey_typematches (hash→HASH,ReJSON-RL→JSON); keys of unsearchable types short-circuit to no matches. Empty-prefix ("match all") indexes also respect the key type now. No API shape change.Also fixes the cluster-dedup unit test, which mocked
FT.INFOon the wrong client and only passed because an undefined reply degraded to an empty (match-all) definition — the new type check exposed it.Testing
key-indexes.service.spec.ts— existing cases updated to mockTYPE, plus new cases: HASH index vs JSON key → no match, empty-prefix index respects key type, unsupported key type returns empty without listing indexes (33 backend redisearch tests pass).FT.CREATE idx ON HASH PREFIX 1 "x:"+HSET x:h …+JSON.SET x:j …→ key-indexes returns the index forx:hand nothing forx:j(previously both matched).Closes #RI-8316
🤖 Generated with Claude Code
Note
Low Risk
Scoped browser API behavior fix with no contract changes; adds one Redis TYPE per lookup and stricter matching that reduces incorrect UI links.
Overview
Key-index lookup for the browser “View index” / “Make searchable” flow no longer matches RediSearch indexes on prefix alone.
getKeyIndexesnow runsTYPEon the key, maps hash/JSON replies to indexHASH/JSON, and filters candidates soindex_definition.key_typemust match before prefix rules apply (including empty-prefix “match all” indexes).Keys whose type is not hash or JSON return an empty list without calling
FT._LIST. Response shape is unchanged; behavior fixes false positives (e.g. a JSON key matching a HASH index with the same prefix).Unit tests mock
TYPE, add coverage for type mismatch and unsupported types, and fix cluster dedup mocking soFT.INFOis stubbed on the shard client that actually runs it.Reviewed by Cursor Bugbot for commit 48eaa9d. Bugbot is set up for automated code reviews on this repo. Configure here.