The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #2275 · PR/commit linked
@@ -16,3 +16,4 @@ urllib3<2
vulture>=2.3.0
wheel>=0.30.0
+numpy>=1.24.0
diff --git a/docs/examples/search_vector_similarity_examples.ipynb b/docs/examples/search_vector_similarity_examples.ipynb
index bd1df3c1ef..809dbda4ea 100644
from redis import Redis
from redis.commands.search.field import VectorField
from redis.commands.search.query import Query
r = Redis(host='localhost',port=6379)
schema = (VectorField("v", "HNSW", {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "L2"}),)
r.ft().create_index(schema)
r.hset(f'{1}',mapping={'v':b'\x80\x00\x00\x00'})
q = Query("*=>[KNN 1 @v $vec AS vector_score]").dialect(2)
results = r.ft().search(q, query_params={"vec": b'\x80\x00\x00\x00'}).docs
for m in results:
print(m.v)
print('match emb =', bytes(m.v,'utf-8'))
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix should not be used if the application relies on the previous decoding behavior.\n\nOption C — Workaround\nunder current search result parsing codebase though, maybe we need some ideas from the maintainers.\nWhen NOT to use: This fix should not be used if the application relies on the previous decoding behavior.\n\n
Why This Fix Works in Production
- Trigger: **Description**: The bytes is converted to string in the vector search results and there is an error in this conversion. The bytes including `b'\x80'` is…
- Mechanism: The bytes are incorrectly decoded to strings due to improper handling in the search result parsing code
- Why the fix works: Resolves the issue of incorrect decoding of byte vectors in search results by allowing field-level configuration for decoding. (first fixed release: 7.1.0).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Shows up under Python 3.9.2 in real deployments (not just unit tests).
- The bytes are incorrectly decoded to strings due to improper handling in the search result parsing code
- Production symptom (often without a traceback): **Description**: The bytes is converted to string in the vector search results and there is an error in this conversion. The bytes including `b'\x80'` is converted to a wrong string.
Proof / Evidence
- GitHub issue: #2275
- Fix PR: https://github.com/redis/redis-py/pull/3309
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-07
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.60
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This issue seems to be resolved with PR#3309 - which is included in released client version 5.1.0 and I'm closing it for now”
“What about using "backslashreplace" mode instead of "ignore"?”
“@kamyabzad I think in this case, we should get the original bytes as result, rather than try any kind of unicode decoding? Since user may…”
Failure Signature (Search String)
- **Description**: The bytes is converted to string in the vector search results and there is an error in this conversion. The bytes including `b'\x80'` is converted to a wrong
- schema = (VectorField("v", "HNSW", {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "L2"}),)
Copy-friendly signature
Failure Signature
-----------------
**Description**: The bytes is converted to string in the vector search results and there is an error in this conversion. The bytes including `b'\x80'` is converted to a wrong string.
schema = (VectorField("v", "HNSW", {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "L2"}),)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
**Description**: The bytes is converted to string in the vector search results and there is an error in this conversion. The bytes including `b'\x80'` is converted to a wrong string.
schema = (VectorField("v", "HNSW", {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "L2"}),)
Minimal Reproduction
from redis import Redis
from redis.commands.search.field import VectorField
from redis.commands.search.query import Query
r = Redis(host='localhost',port=6379)
schema = (VectorField("v", "HNSW", {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "L2"}),)
r.ft().create_index(schema)
r.hset(f'{1}',mapping={'v':b'\x80\x00\x00\x00'})
q = Query("*=>[KNN 1 @v $vec AS vector_score]").dialect(2)
results = r.ft().search(q, query_params={"vec": b'\x80\x00\x00\x00'}).docs
for m in results:
print(m.v)
print('match emb =', bytes(m.v,'utf-8'))
Environment
- Python: 3.9.2
What Broke
Search results return incorrect string representations of byte vectors, leading to data misinterpretation.
Why It Broke
The bytes are incorrectly decoded to strings due to improper handling in the search result parsing code
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install redis==7.1.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
under current search result parsing codebase though, maybe we need some ideas from the maintainers.
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/redis/redis-py/pull/3309
First fixed release: 7.1.0
Last verified: 2026-02-07. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application relies on the previous decoding behavior.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 7.1.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.