-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Python: fix(redis): wrap IndexDefinition prefix in list; use _get_redis_key in JSON delete #13970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
71226fe
1f578ac
2013d1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,7 +278,7 @@ async def ensure_collection_exists(self, **kwargs) -> None: | |
| raise VectorStoreOperationException("Invalid index type supplied.") | ||
| fields = _definition_to_redis_fields(self.definition, self.collection_type) | ||
| index_definition = IndexDefinition( | ||
| prefix=f"{self.collection_name}:", index_type=INDEX_TYPE_MAP[self.collection_type] | ||
| prefix=[f"{self.collection_name}:"], index_type=INDEX_TYPE_MAP[self.collection_type] | ||
| ) | ||
| await self.redis_database.ft(self.collection_name).create_index(fields, definition=index_definition, **kwargs) | ||
|
Comment on lines
279
to
286
|
||
|
|
||
|
|
@@ -706,7 +706,7 @@ def _add_key(self, key: TKey, record: dict[str, Any]) -> dict[str, Any]: | |
|
|
||
| @override | ||
| async def _inner_delete(self, keys: Sequence[str], **kwargs: Any) -> None: | ||
| await asyncio.gather(*[self.redis_database.json().delete(key, **kwargs) for key in keys]) | ||
| await asyncio.gather(*[self.redis_database.json().delete(self._get_redis_key(key), **kwargs) for key in keys]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test coverage. This fix is correct — |
||
|
|
||
| @override | ||
| def _serialize_dicts_to_store_models( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design mismatch & missing test coverage. Wrapping the prefix in a list fixes the redis-py API usage, but the index prefix is still unconditionally set to
collection_name:. BothRedisHashsetCollectionandRedisJsonCollectiondefaultprefix_collection_name_to_key_names=False(redis.py:524, redis.py:652), so_get_redis_keyreturns the raw key (redis.py:250-253). Defaultupsertwritesid1while the index only matchestest:-prefixed keys. The prefix should be derived fromprefix_collection_name_to_key_names. Additionally,test_create_index(test_redis_store.py:294) mockscreate_indexwithout inspecting its arguments — consider asserting on the mock'scall_argsto verify thedefinitionwas constructed with the correct prefix.