HASH-backed `SearchIndex.fetch()` raises `UnicodeDecodeError` with `decode_responses=True`
Maintainer thường phản hồi trong vòng 4 ngày
@mohsinaliwork686-rgb đang làm issue này rồi.
Từ ngày 2/12/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
Hướng nghiên cứu
Start in the HASH storage read paths, HashStorage._get() and its async counterpart, which call hgetall; compare the search paths in redisvl/index/index.py and redisvl/redis/utils.py for NEVER_DECODE handling. Add sync and async regression coverage for both decode_responses settings, verifying the text and original embedding bytes, then run the relevant tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
SearchIndex.fetch() raises UnicodeDecodeError when fetching an existing HASH record containing a binary embedding through a Redis client configured with decode_responses=True.
Loading the record succeeds. Fetching it with decode_responses=False also succeeds.
Verified with Python 3.13.14, RedisVL 0.33.0, redis-py 8.1.0, and Redis 8.4.8 using Docker.
Related: [redis/redis-vl-python#844](https://github.com/redis/redis-vl-python/pull/844) also edits HashStorage.get()/aget() to handle missing records.
Cause
HashStorage._get() calls client.hgetall(key). With decode_responses=True, redis-py attempts to decode every HASH value, including the binary embedding. Embedding bytes that are invalid UTF-8 cause the read to fail before RedisVL receives the record.
The async path through aget()/_aget() makes the same hgetall call. That path has not been tested in this reproduction.
Reproduction
Requires Redis with Search support. REDIS_URL defaults to redis://localhost:6379.
import os
from uuid import uuid4
from redis import Redis
from redisvl.index import SearchIndex
from redisvl.redis.utils import array_to_buffer
for decode in (False, True):
client = Redis.from_url(
os.getenv("REDIS_URL", "redis://localhost:6379"),
decode_responses=decode,
)
name = f"fetch_decode_{uuid4().hex}"
index = SearchIndex.from_dict(
{
"index": {
"name": name,
"prefix": name,
"storage_type": "hash",
},
"fields": [
{"name": "text", "type": "text"},
{
"name": "embedding",
"type": "vector",
"attrs": {
"algorithm": "flat",
"dims": 4,
"datatype": "float32",
"distance_metric": "cosine",
},
},
],
},
redis_client=client,
)
index.create()
try:
index.load(
[{
"text": "hello",
"embedding": array_to_buffer([0.1] * 4, "float32"),
}],
keys=[index.key("doc")],
)
try:
record = index.fetch("doc")
print(
f"decode_responses={decode}: {record['text']!r}, "
f"embedding type={type(record['embedding']).__name__}"
)
except UnicodeDecodeError as exc:
print(
f"decode_responses={decode}: "
f"{type(exc).__name__}: {exc}"
)
finally:
index.delete(drop=True)
client.close()
Current behaviour
Fetching succeeds with decode_responses=False and raises with decode_responses=True.
decode_responses=False: 'hello', embedding type=bytes
decode_responses=True: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 0: invalid continuation byte
Expected behaviour
Both fetches should succeed and return the stored record. In each case, record["text"] should equal "hello" and record["embedding"] should contain the exact bytes originally written.
The reproduction should print the following output.
decode_responses=False: 'hello', embedding type=bytes
decode_responses=True: 'hello', embedding type=bytes
Suggested fix
Read the HASH reply with redis-py’s NEVER_DECODE option, following the search paths in redisvl/index/index.py and redisvl/redis/utils.py, then decode the non-vector fields while preserving vector fields as bytes.
NEVER_DECODE applies to the entire reply. Keep these reads in the existing non-transactional pipelines, since the option is ignored inside MULTI/EXEC.
Apply the handling to both synchronous and asynchronous HASH reads. Add regression coverage for decode_responses=True and False, asserting that fetching succeeds and the original embedding bytes are preserved.
- Ngôn ngữ chính
- Python
- Star
- 435
- Fork
- 123
- Merge trung bình
- 8 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 39
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của redis/redis-vl-python
-
SearchIndex.drop_keys does not validate cluster hash-tag co-location (inconsistent with drop_documents)Có thể đã có người làm @Hashim1999164 đã nhận 47 ngày trước. Đang mởbug good first issue index
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redis/redis-vl-python#601 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
redis/redis-vl-python#889 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Add image embedding to the Cohere vectorizer (Embed v4 and v5)Có thể đã có người làm @rahulsjha đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
redis/redis-vl-python#888 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
redis/redis-vl-python#887 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
GoogleGenAIVectorizer.embed_many fails on gemini-embedding-2 for batches of more than one inputCó thể đã có người làm @pcbeingused33 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
redis/redis-vl-python#886 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của redis/redis-vl-python
Issue tương tự
-
A JSON chat answer blocks the backend event loop for the whole RAG runCó thể đã có người làm @NopeCharon đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
The-OpenROAD-Project/ORAssistant#656 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorCó thể đã có người làm @jejjohnson đã nhận hôm nay. Đang mởtype:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jejjohnson/integrix#144 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
finos/ai-governance-framework#459 ·
-
slurm: a case outcome nested too deep crashes status/collect instead of reading as no outcomeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày