Skip to content

fix(python): apply collection name prefix to keys in RedisJsonCollection._inner_delete (#13904) - #14852

Open
Parchuri Poojith Kumar (poojithparchuri-iiitk) wants to merge 1 commit into
microsoft:mainfrom
poojithparchuri-iiitk:fix-redis-json-delete-prefixed-key
Open

Parchuri Poojith Kumar (poojithparchuri-iiitk) wants to merge 1 commit into
microsoft:mainfrom
poojithparchuri-iiitk:fix-redis-json-delete-prefixed-key

Conversation

@poojithparchuri-iiitk

Summary

Fixes #13904

In RedisJsonCollection, when prefix_collection_name_to_key_names=True, records are upserted with a collection prefix (e.g. {collection_name}:{key}). However, _inner_delete was passing bare key directly to self.redis_database.json().delete(key) instead of calling self._get_redis_key(key).

As a result, delete operations were targeting non-existent bare keys, returning 0, and silently failing to remove the record.

Changes

  • In python/semantic_kernel/connectors/redis.py:
    • Updated RedisJsonCollection._inner_delete to call self._get_redis_key(key) for each key, aligning its behavior with RedisHashsetCollection._inner_delete.
  • In python/tests/unit/connectors/memory/test_redis_store.py:
    • Added unit test test_delete_with_prefix parameterized across both hashset and json to verify that self._get_redis_key(key) (e.g. "test:id1") is properly passed to the underlying redis command.

Testing

  • Ran pytest tests/unit/connectors/memory/test_redis_store.py locally — all 31 unit tests passed in 3.56s.

AI Disclosure: I used AI to identify the un-prefixed key discrepancy in _inner_delete and draft the regression test; I tested and reviewed the changes locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the change making Redis JSON deletion honor collection-name prefixes.

No open issues 🎉

What changed in this PR

Fixes #13904 by making Redis JSON deletion honor collection-name prefixes, matching the existing key handling used by other operations.

Changes:

  • Applies _get_redis_key() to each key before issuing JSON delete commands.
  • Adds a parameterized regression test verifying prefixed delete keys for both hashset and JSON collections.
File Description
python/​tests/​unit/​connectors/​memory/​test_redis_store.py Adds prefixed-key deletion assertions for both collection types.
python/​semantic_kernel/​connectors/​redis.py Uses the configured key prefix when deleting JSON records.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — 4cc7fa43 Deployed Nov 21, 2026 by poojithparchuri-iiitk via add_label #29787
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.

Python: Bug: RedisJsonCollection.delete() silently fails when prefix_collection_name_to_key_names is enabled

2 participants