fix: add cluster hash-tag validation to SearchIndex.drop_keys#614
Open
algojogacor wants to merge 1 commit into
Open
fix: add cluster hash-tag validation to SearchIndex.drop_keys#614algojogacor wants to merge 1 commit into
algojogacor wants to merge 1 commit into
Conversation
Add the same RedisCluster hash-tag validation to SearchIndex.drop_keys that drop_documents already has. This prevents cross-slot errors when calling drop_keys with keys that hash to different slots on a clustered Redis deployment. The check raises ValueError when the Redis client is a RedisCluster instance and the provided keys don't share a hash tag, consistent with drop_documents behavior. Closes redis#601
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
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.
Summary
Fixes #601 —
SearchIndex.drop_keysshould validate cluster hash-tag co-location, consistent withdrop_documents.Root Cause
drop_keys(redisvl/index/index.py:826) calledself._redis_client.delete(*keys)on a RedisCluster without checking whether all keys share a hash tag. On clustered Redis Enterprise, multi-keyDELacross different hash slots raisesCROSSSLOTerrors or silently fails depending on the redis-py client mode.Meanwhile,
drop_documents(line 860-866) already had a guard:This inconsistency meant
SemanticCache.drop()behaved differently depending on whether callers used thekeys=path (viadrop_keys) or theids=path (viadrop_documents).Fix
Added the same
isinstance(self._redis_client, RedisCluster) and _keys_share_hash_tag()guard todrop_keys, raising the sameValueErrorwith the same message.Changes
redisvl/index/index.py(+7): Added cluster hash-tag validation indrop_keysmethodTesting
drop_documentsisinstancecheck gates the validationNote
Low Risk
Low risk, small guard change that only affects multi-key deletes on
RedisClusterby failing fast with a clearValueErrorinstead of triggering cross-slotDELbehavior.Overview
Adds Redis Cluster co-location validation to
SearchIndex.drop_keys: when deleting a list of keys onRedisCluster, it now checks_keys_share_hash_tag(keys)and raisesValueErrorif keys span hash slots.This aligns
drop_keysbehavior withdrop_documentsand avoidsCROSSSLOTissues for multi-keyDELin clustered environments.Reviewed by Cursor Bugbot for commit 79a77cf. Bugbot is set up for automated code reviews on this repo. Configure here.