go
data_error
ai_generated
true
rpc 错误:代码 = InvalidArgument 描述 = 字段 status 的枚举值无效:99
rpc error: code = InvalidArgument desc = invalid enum value: 99 for field status
ID: go/grpc-out-of-range-enum-value
80%修复率
87%置信度
0证据数
2024-03-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.0 | active | — | — | — |
根因分析
客户端发送的整数未映射到 proto 中定义的任何枚举值。
English
The client sends an integer that doesn't map to any defined enum value in the proto.
解决方案
-
95% 成功率
if status < pb.Status_STATUS_UNKNOWN || status > pb.Status_STATUS_DONE { return error } -
80% 成功率
// Use protoreflect to check if value is defined.
无效尝试
常见但无效的做法:
-
80% 失败
Go will allow the conversion but protobuf deserialization will fail.
-
100% 失败
The server will reject the message.