go
data_error
ai_generated
partial
error: proto: field "status" has invalid enum value: 99
ID: go/grpc-protobuf-enum-out-of-range
80%Fix Rate
83%Confidence
0Evidence
2024-05-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0 | active | — | — | — |
Root Cause
The protobuf message contains an enum field with a numeric value not defined in the .proto file, often due to version drift.
generic中文
protobuf消息包含一个枚举字段,其数值未在.proto文件中定义,通常是由于版本漂移。
Workarounds
-
90% success Add the missing enum value to the .proto file and regenerate.
enum Status { UNKNOWN = 0; ACTIVE = 1; INACTIVE = 2; CUSTOM = 99; } -
60% success Use proto.EnumValueMap to map unknown values to a default.
import "google.golang.org/protobuf/types/known/anypb" // Not directly supported; requires custom unmarshaler
Dead Ends
Common approaches that don't work:
-
Ignore the error and continue processing.
100% fail
Unmarshal will fail completely, no partial data.
-
Cast the value to int and treat as unknown.
95% fail
Protobuf enums are strict; unknown values cause rejection.