Skip to content

RI-8316 Match key type when finding indexes for a key#6200

Open
dantovska wants to merge 1 commit into
mainfrom
be/bugfix/RI-8316/match-key-type-in-key-indexes
Open

RI-8316 Match key type when finding indexes for a key#6200
dantovska wants to merge 1 commit into
mainfrom
be/bugfix/RI-8316/match-key-type-in-key-indexes

Conversation

@dantovska

@dantovska dantovska commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What

The redisearch/key-indexes endpoint (behind "View index" / "Make searchable" in the key details panel) matched indexes by prefix only — the index definition's key_type was returned but never compared. A JSON key like foo:bar therefore matched an FT.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 TYPE and only returns indexes whose key_type matches (hashHASH, ReJSON-RLJSON); 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.INFO on the wrong client and only passed because an undefined reply degraded to an empty (match-all) definition — the new type check exposed it.

Testing

  • Unit: key-indexes.service.spec.ts — existing cases updated to mock TYPE, 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).
  • Manual against a live database: FT.CREATE idx ON HASH PREFIX 1 "x:" + HSET x:h … + JSON.SET x:j … → key-indexes returns the index for x:h and nothing for x: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. getKeyIndexes now runs TYPE on the key, maps hash/JSON replies to index HASH/JSON, and filters candidates so index_definition.key_type must 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 so FT.INFO is 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.

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>
@dantovska dantovska requested a review from a team as a code owner July 13, 2026 17:24
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 93.08% 16517/17744
🟡 Branches 75.23% 5254/6984
🟢 Functions 87.36% 2530/2896
🟢 Lines 92.94% 15794/16993

Test suite run success

3660 tests passing in 319 suites.

Report generated by 🧪jest coverage report action from 48eaa9d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant