Describe the bug
The Python Redis connector sends FT.CREATE with the PREFIX argument split into one prefix per character of the collection name, instead of one prefix equal to "<collection_name>:".
Example observed on the wire for a collection named redis_json_list_data_model:
FT.CREATE redis_json_list_data_model ON JSON
PREFIX 27 r e d i s _ j s o n _ l i s t _ d a t a _ m o d e l :
SCORE 1.0 SCHEMA ...
RediSearch on Redis Stack silently accepts the malformed command and the connector appears to work for simple single-collection usage.
Root cause (client-side): python/semantic_kernel/connectors/redis.py:281 passes a plain string to redis-py's IndexDefinition(prefix=...). redis-py treats that argument as an iterable of prefixes and iterates the string character-by-character.
Expected behavior
FT.CREATE for an SK-managed collection should register exactly one key-space prefix equal to "<collection_name>:", so that the index only matches keys written for this collection.
FT.CREATE redis_json_list_data_model ON JSON
PREFIX 1 redis_json_list_data_model:
SCORE 1.0 SCHEMA ...
To Reproduce
Prerequisites: a Redis Stack server reachable on localhost:6379, redis-cli, and a working Python SK dev environment.
- Install Python SK per (
python/DEV_SETUP.md):
cd python && make install-sk PYTHON_VERSION=3.12
- Start Redis Stack on port 6379. Example:
podman run -d -p 6379:6379 docker.io/redis/redis-stack:latest
- In a separate terminal, attach
MONITOR to the server:
redis-cli -h localhost -p 6379 MONITOR
- From
python/, run the Redis integration tests:
REDIS_CONNECTION_STRING="redis://localhost:6379" \
uv run pytest tests/integration/memory/test_vector_store.py -k redis -v
- Inspect the
MONITOR output for the FT.CREATE lines. Each one contains PREFIX <N> where N equals the length of the collection name, followed by that many single-character prefixes.
On Redis Stack the tests pass (the bug is silent).
Platform
- Language: Python
- Source:
main branch of microsoft/semantic-kernel (SK version 1.41.2 as reported by semantic_kernel.__version__)
redis-py version: 6.4.0
- Backends tested:
- Redis Stack 7.4.7 (RediSearch v21020, ReJSON v20809) — bug is silent,
FT.CREATE accepted
- AI model: [e.g. OpenAI:GPT-4o-mini(2024-07-18)]
- IDE: Kiro
- OS: macOS 25.4.0 (Darwin), arm64
Additional context
Correctness on Redis: indexes register unintended single-character prefixes. In multi-collection deployments on a shared Redis, collections whose names share any character will register overlapping prefixes and can match each other's keys.
Describe the bug
The Python Redis connector sends
FT.CREATEwith thePREFIXargument split into one prefix per character of the collection name, instead of one prefix equal to"<collection_name>:".Example observed on the wire for a collection named
redis_json_list_data_model:RediSearch on Redis Stack silently accepts the malformed command and the connector appears to work for simple single-collection usage.
Root cause (client-side):
python/semantic_kernel/connectors/redis.py:281passes a plain string toredis-py'sIndexDefinition(prefix=...).redis-pytreats that argument as an iterable of prefixes and iterates the string character-by-character.Expected behavior
FT.CREATEfor an SK-managed collection should register exactly one key-space prefix equal to"<collection_name>:", so that the index only matches keys written for this collection.To Reproduce
Prerequisites: a Redis Stack server reachable on localhost:6379,
redis-cli, and a working Python SK dev environment.python/DEV_SETUP.md):MONITORto the server:python/, run the Redis integration tests:REDIS_CONNECTION_STRING="redis://localhost:6379" \ uv run pytest tests/integration/memory/test_vector_store.py -k redis -vMONITORoutput for theFT.CREATElines. Each one containsPREFIX <N>whereNequals the length of the collection name, followed by that many single-character prefixes.On Redis Stack the tests pass (the bug is silent).
Platform
mainbranch ofmicrosoft/semantic-kernel(SK version1.41.2as reported bysemantic_kernel.__version__)redis-pyversion: 6.4.0FT.CREATEacceptedAdditional context
Correctness on Redis: indexes register unintended single-character prefixes. In multi-collection deployments on a shared Redis, collections whose names share any character will register overlapping prefixes and can match each other's keys.