Empty list cannot be parsed by `repeated`
还没有人认领这个 Issue。
评估
调研方向
从生成的 init.py 中调用消息解析的部分开始,然后检查 betterproto/init.py 中 FromString 和 parse 附近的代码,使用提供的 GenerateRequest(messages=[]) 示例和 protoc 命令重现该故障。当空的 repeated 字段能够在没有 Pydantic 验证错误的情况下成功解码时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Versions
betterproto[compiler]==2.0.0b6
grpcio-tools
pydantic==1.10.8
I get the following error on the server side:
023-07-10 15:48:08,980 - 140154842511168 - server.py-server:468 - ERROR: Application error
Traceback (most recent call last):
File "/worker-py/.direnv/python-3.10/lib/python3.10/site-packages/grpclib/server.py", line 446, in request_handler
await method_func(stream)
File "/worker-py/generated/__init__.py", line 157, in __rpc_teamlead_reply
request = await stream.recv_message()
File "/worker-py/.direnv/python-3.10/lib/python3.10/site-packages/grpclib/server.py", line 136, in recv_message
message = await recv_message(self._stream, self._codec, self._recv_type)
File "/worker-py/.direnv/python-3.10/lib/python3.10/site-packages/grpclib/stream.py", line 32, in recv_message
message = codec.decode(message_bin, message_type)
File "/worker-py/.direnv/python-3.10/lib/python3.10/site-packages/grpclib/encoding/proto.py", line 54, in decode
return message_type.FromString(data)
File "/worker-py/.direnv/python-3.10/lib/python3.10/site-packages/betterproto/__init__.py", line 1052, in FromString
return cls().parse(data)
File "pydantic/dataclasses.py", line 286, in pydantic.dataclasses._add_pydantic_validation_attributes.handle_extra_init
File "<string>", line 4, in __init__
File "pydantic/dataclasses.py", line 308, in pydantic.dataclasses._add_pydantic_validation_attributes.new_post_init
File "pydantic/dataclasses.py", line 425, in pydantic.dataclasses._dataclass_validate_values
pydantic.error_wrappers.ValidationError: 1 validation error for GenerateRequest
conversation
value is not a valid list (type=type_error.list)
proto defintion
service ReplyGenerator {
rpc Reply(GenerateRequest) returns (stream StreamReply) {}
}
message GenerateRequest {
repeated Message messages = 2;
}
Calling it like this from client:
async for res in service.teamlead_reply(guided_chat.GenerateRequest(messages=[])):
Compilation was done with:
PROTO_DIR=protos
GEN_DIR=generated
protofiles=$(find "${PROTO_DIR}" -name "*.proto")
python -m grpc_tools.protoc -I "${PROTO_DIR}" --python_betterproto_opt=pydantic_dataclasses --python_betterproto_out="${GEN_DIR}" ${protofiles}
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 235
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
danielgtaylor/python-betterproto 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
-
难度 5/5 一周以上 新手友好度 15/100
-
bug investigation needed
难度 3/5 1-2 天 新手友好度 42/100
-
bug investigation needed
难度 3/5 1-2 天 新手友好度 45/100
-
bug investigation needed
难度 4/5 3-5 天 新手友好度 38/100
danielgtaylor/python-betterproto#676 · 3 条评论 ·
查看 danielgtaylor/python-betterproto 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
volcengine/OpenViking#6445 ·
维护者通常 1 天内回复
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be edited可能已有人在做 @ManyaJain111 今天认领。 未关闭bug enhancement possible-duplicate
难度 2/5 1-3 小时 新手友好度 77/100
AOSSIE-Org/PictoPy#1637 · 4 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
deepspeedai/DeepSpeed#8884 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
flagos-ai/FlagQuantum#718 ·
维护者通常 1 天内回复
-
bug CI-failure high priority
难度 1/5 1 小时以内 新手友好度 86/100
vllm-project/afd-plugin#483 ·
维护者通常 1 天内回复