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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 90% 成功率
    Run protoc with the updated status enum definition.
  2. 80% 成功率
    if status < 0 || status > 3 { return fmt.Errorf("invalid status") }

无效尝试

常见但无效的做法:

  1. 80% 失败

    The value 99 is not a valid enum constant, so casting will not help.

  2. 70% 失败

    Protobuf enums are strict by default; you would need to use a wrapper type.