Searches that return binary fields fail with RESP3 and decode_responses=True (batch_query, and every search on a cluster)
维护者通常 4 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
调研方向
Read the four FT.SEARCH call sites named in redisvl/index/index.py and redisvl/redis/utils.py, then compare their argument handling with redis-py's search() implementation. Check the open pull request #891 and issue #877 for ongoing work. Done means batch queries and cluster searches return binary vector fields with RESP3 and decode_responses=True, while RESP2 behavior remains covered by tests.
由索引模型根据 Issue 内容生成。
描述
Python version
3.13.9
Package versions
- redisvl on
main(92e93d20) - redis 8.1.0
Steps to reproduce
- Create a client with
protocol=3, decode_responses=True. - Build a HASH index with a vector field and load one document.
- Run
batch_querywith a query that returns the vector field. On a Redis Cluster,queryis enough.
Expected behavior
batch_query returns the same documents as query does on a single node, and both work on a cluster.
Actual behavior
The search fails while decoding the vector bytes:
| Client | Single node | 3-primary Redis Cluster |
|---|---|---|
query |
works | RedisSearchError: Unexpected error while searching: 'utf-8' codec can't decode byte 0xcd ... |
batch_query |
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 0: invalid continuation byte |
same UnicodeDecodeError |
Each cell is the same for SearchIndex and AsyncSearchIndex, and with or without hiredis installed. With protocol=2, decode_responses=True, or with protocol=3 and no decode_responses, every case works.
Four places send FT.SEARCH themselves and set NEVER_DECODE only when the protocol isn't 3:
SearchIndex.batch_search(redisvl/index/index.py:2094)AsyncSearchIndex.batch_search(redisvl/index/index.py:3444)cluster_search(redisvl/redis/utils.py:440)async_cluster_search(redisvl/redis/utils.py:465)
That matches what redis-py 7.x did. redis-py 8.1 sets NEVER_DECODE on every protocol in its own search() (redis/commands/search/commands.py:1338 and :1877), because a search reply can contain binary values such as vectors, and its RESP3 parser decodes text fields itself. So without NEVER_DECODE, the client tries to decode the vector bytes as UTF-8 and fails. On a single node, query() doesn't hit this because it calls redis-py's search(); on a cluster it goes through cluster_search or async_cluster_search instead.
Environment
macOS, Redis 8.2 in Docker: a single node, and a 3-primary Redis Cluster with no replicas.
Code sample
import time
import numpy as np
import redis
from redisvl.index import SearchIndex
from redisvl.query import VectorQuery
schema = {
"index": {"name": "resp3_decode", "prefix": "resp3_decode", "storage_type": "hash"},
"fields": [
{"name": "name", "type": "tag"},
{
"name": "embedding",
"type": "vector",
"attrs": {
"dims": 4,
"distance_metric": "cosine",
"algorithm": "flat",
"datatype": "float32",
},
},
],
}
# For the cluster case, use redis.cluster.RedisCluster.from_url(...) here.
client = redis.Redis.from_url(
"redis://localhost:6379", protocol=3, decode_responses=True
)
index = SearchIndex.from_dict(schema, redis_client=client)
index.create(overwrite=True, drop=True)
index.load(
[{"name": "a", "embedding": np.array([-0.1, 0.2, 0.3, 0.4], dtype=np.float32).tobytes()}]
)
time.sleep(0.5)
query = VectorQuery(
vector=[0.1, 0.2, 0.3, 0.4],
vector_field_name="embedding",
return_fields=["name", "embedding"],
)
print(index.query(query)) # works on a single node, fails on a cluster
print(index.batch_query([query])) # UnicodeDecodeError
Suggested fix
Set NEVER_DECODE the way the installed redis-py does, in one shared helper used by all four places, and add a test that runs batch_query with this client configuration on RESP2 and RESP3. #877 adds a fifth copy of the same condition in AsyncSearchIndex.search; the review there suggests calling redis-py's search() instead.
- 主要语言
- Python
- 星标
- 435
- 派生
- 123
- 平均合并
- 8 天 1 小时
- 30 天内合并 PR
- 39
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
redis/redis-vl-python 的其他 Issue
-
SearchIndex.drop_keys does not validate cluster hash-tag co-location (inconsistent with drop_documents)可能已有人在做 @Hashim1999164 于 47 天前认领。 未关闭bug good first issue index
难度 2/5 1-3 小时 新手友好度 78/100
redis/redis-vl-python#601 · 2 条评论 ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
redis/redis-vl-python#889 ·
维护者通常 4 天内回复
-
Add image embedding to the Cohere vectorizer (Embed v4 and v5)可能已有人在做 @rahulsjha 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 58/100
redis/redis-vl-python#888 · 2 条评论 ·
维护者通常 4 天内回复
-
难度 5/5 一周以上 新手友好度 38/100
redis/redis-vl-python#887 ·
维护者通常 4 天内回复
-
GoogleGenAIVectorizer.embed_many fails on gemini-embedding-2 for batches of more than one input可能已有人在做 @pcbeingused33 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
redis/redis-vl-python#886 ·
维护者通常 4 天内回复
查看 redis/redis-vl-python 的全部 Issue
相似的 Issue
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionError可能已有人在做 @jejjohnson 今天认领。 未关闭type:bug
难度 2/5 1-3 小时 新手友好度 72/100
jejjohnson/integrix#144 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
finos/ai-governance-framework#459 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
freelawproject/litigant-portal#1307 ·
维护者通常 2 天内回复
-
type/bug
难度 1/5 1 小时以内 新手友好度 86/100
h2oai/h2o-llmstudio#1163 ·
维护者通常 1 天内回复