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-invalid-argument-enum
80%修复率
85%置信度
0证据数
2024-04-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.x | active | — | — | — |
根因分析
客户端为 protobuf 枚举字段发送了一个未在枚举中定义的整数值。这通常是因为客户端和服务器使用了不同版本的 .proto 定义。
English
The client sent an integer value for a protobuf enum field that is not defined in the enum. This often happens when the client and server have different versions of the .proto definition.
解决方案
-
90% 成功率
Run protoc with the updated status enum definition.
-
80% 成功率
if status < 0 || status > 3 { return fmt.Errorf("invalid status") }
无效尝试
常见但无效的做法:
-
80% 失败
The value 99 is not a valid enum constant, so casting will not help.
-
70% 失败
Protobuf enums are strict by default; you would need to use a wrapper type.