go data_error ai_generated partial

error: proto: field "status" has invalid enum value: 99

ID: go/grpc-protobuf-enum-out-of-range

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2024-05-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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

  1. 90% success Add the missing enum value to the .proto file and regenerate.
    enum Status { UNKNOWN = 0; ACTIVE = 1; INACTIVE = 2; CUSTOM = 99; }
  2. 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:

  1. Ignore the error and continue processing. 100% fail

    Unmarshal will fail completely, no partial data.

  2. Cast the value to int and treat as unknown. 95% fail

    Protobuf enums are strict; unknown values cause rejection.