Skip to content

Commit f56e610

Browse files
Support Redis 8 (#282)
This PR adds testing support for Redis 8 (currently `redis:8.0-M03` from Docker) to our GitHub Actions pipeline. Overall, our entire test suite passed against Redis 8 with one notable exception: **Breaking Change in Redis 8, Dialect 2 Only** When a search query references a field that is not present in the index schema, Redis 8 now raises: ``` redis.exceptions.ResponseError: Unknown field at offset NN near <unknown-field-name> ``` Previously (and in other dialects), Redis would allow such queries but return empty results. This new behavior is arguably more correct, but it breaks a test that expects an empty result when searching on a non-indexed field. ## Context and Discussion A single test failed where our code intentionally queries a field not in the index, expecting empty results. With Redis 8, Dialect 2, this now raises an error. The team discussed whether to: - Adjust the test to skip or otherwise handle this new behavior (since querying a non-indexed field arguably should be an error). - Catch and raise a more user-friendly message in our library. The Redis error text can be cryptic, so providing a clearer explanation to users might be beneficial. ## Decision - Testing: We will proceed with adding Redis 8 to our CI matrix. - The Failing Test: We will update this test to either skip on Redis 8 or handle the error more gracefully. - Error Messaging: We may consider adding a better exception message so that developers get a more understandable error when they inadvertently query non-indexed fields. But this will go in a different PR.
1 parent b751db7 commit f56e610

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@ env:
1818

1919
jobs:
2020
test:
21-
name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis-stack ${{matrix.redis-stack-version}}]
21+
name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} [redis ${{ matrix.redis-version }}]
2222
runs-on: ubuntu-latest
2323

2424
strategy:
2525
fail-fast: false
2626
matrix:
2727
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
2828
connection: ['hiredis', 'plain']
29-
redis-stack-version: ['6.2.6-v9', 'latest', 'edge']
30-
31-
services:
32-
redis:
33-
image: redis/redis-stack-server:${{matrix.redis-stack-version}}
34-
ports:
35-
- 6379:6379
29+
redis-version: ['6.2.6-v9', 'latest', '8.0-M03']
3630

3731
steps:
3832
- name: Check out repository
@@ -58,17 +52,21 @@ jobs:
5852
run: |
5953
poetry add hiredis
6054
61-
- name: Set Redis version
55+
- name: Set Redis image name
6256
run: |
63-
echo "REDIS_VERSION=${{ matrix.redis-stack-version }}" >> $GITHUB_ENV
57+
if [[ "${{ matrix.redis-version }}" == "8.0-M03" ]]; then
58+
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
59+
else
60+
echo "REDIS_IMAGE=redis/redis-stack-server:${{ matrix.redis-version }}" >> $GITHUB_ENV
61+
fi
6462
6563
- name: Authenticate to Google Cloud
6664
uses: google-github-actions/auth@v1
6765
with:
6866
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
6967

7068
- name: Run tests
71-
if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest'
69+
if: matrix.connection == 'plain' && matrix.redis-version == 'latest'
7270
env:
7371
OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }}
7472
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
@@ -86,12 +84,12 @@ jobs:
8684
make test-all
8785
8886
- name: Run tests
89-
if: matrix.connection != 'plain' || matrix.redis-stack-version != 'latest'
87+
if: matrix.connection != 'plain' || matrix.redis-version != 'latest'
9088
run: |
9189
make test
9290
9391
- name: Run notebooks
94-
if: matrix.connection == 'plain' && matrix.redis-stack-version == 'latest'
92+
if: matrix.connection == 'plain' && matrix.redis-version == 'latest'
9593
env:
9694
OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }}
9795
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
@@ -106,6 +104,7 @@ jobs:
106104
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
107105
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
108106
run: |
107+
docker run -d --name redis -p 6379:6379 redis/redis-stack-server:latest
109108
make test-notebooks
110109
111110
docs:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def redis_container(request):
2525

2626
# Set the Compose project name so containers do not clash across workers
2727
os.environ["COMPOSE_PROJECT_NAME"] = f"redis_test_{worker_id}"
28-
os.environ.setdefault("REDIS_VERSION", "edge")
28+
os.environ.setdefault("REDIS_IMAGE", "redis/redis-stack-server:latest")
2929

3030
compose = DockerCompose(
3131
context="tests",

tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3.9"
22
services:
33
redis:
4-
image: "redis/redis-stack:${REDIS_VERSION}"
4+
image: "${REDIS_IMAGE}"
55
ports:
66
- "6379"
77
environment:

tests/integration/test_llmcache.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def test_complex_filters(cache_with_filters):
770770
assert len(results) == 1
771771

772772

773-
def test_index_updating(redis_url):
773+
def test_cache_index_overwrite(redis_url):
774774
cache_no_tags = SemanticCache(
775775
name="test_cache",
776776
redis_url=redis_url,
@@ -785,15 +785,22 @@ def test_index_updating(redis_url):
785785
# filterable_fields not defined in schema, so no tags will match
786786
tag_filter = Tag("some_tag") == "abc"
787787

788-
response = cache_no_tags.check(
789-
prompt="this prompt has a tag",
790-
filter_expression=tag_filter,
791-
)
788+
try:
789+
response = cache_no_tags.check(
790+
prompt="this prompt has a tag",
791+
filter_expression=tag_filter,
792+
)
793+
except Exception as e:
794+
# This will fail in Redis 8+ on query dialect 2
795+
if "Unknown field" in str(e):
796+
response = []
797+
else:
798+
raise
799+
792800
assert response == []
793801

794802
with pytest.raises((RedisModuleVersionError, ValueError)):
795-
796-
cache_with_tags = SemanticCache(
803+
SemanticCache(
797804
name="test_cache",
798805
redis_url=redis_url,
799806
filterable_fields=[{"name": "some_tag", "type": "tag"}],

0 commit comments

Comments
 (0)