{
  "id": "grpc/protobuf-unknown-field-enum",
  "signature": "INTERNAL: grpc: unknown enum value 42 for field 'Status' in protobuf message",
  "signature_zh": "内部错误：gRPC：protobuf 消息中字段 'Status' 的未知枚举值 42",
  "regex": "INTERNAL: grpc: unknown enum value \\d+ for field '[A-Za-z_]+' in protobuf message",
  "domain": "grpc",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "The server received a protobuf message containing an enum field with a numeric value that is not defined in the proto schema, likely due to version mismatch between client and server protobuf definitions.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务器收到包含枚举字段的 protobuf 消息，该字段的数字值在 proto 模式中未定义，通常是由于客户端和服务器 protobuf 定义版本不匹配。",
  "versions": [
    {
      "version": "protobuf v3.21.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "protobuf v4.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC v1.58.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC v1.62.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Ignoring the error and retrying the RPC will keep failing because the message payload is still invalid.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding a catch-all case in the server's enum handling logic may suppress the error but can lead to silent data corruption.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Rebuilding the server binary without updating the proto files will not fix the mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure client and server use the same .proto file version by running `protoc --version` on both sides and recompiling with identical schema.",
      "success_rate": 0.85,
      "how": "Ensure client and server use the same .proto file version by running `protoc --version` on both sides and recompiling with identical schema.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a fallback enum value like 'UNKNOWN' (value 0) in the proto definition to handle unknown values gracefully: `enum Status { UNKNOWN = 0; ... }`",
      "success_rate": 0.75,
      "how": "Add a fallback enum value like 'UNKNOWN' (value 0) in the proto definition to handle unknown values gracefully: `enum Status { UNKNOWN = 0; ... }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use protobuf's `allow_unknown` field option in the server code to ignore unknown enum values: `options.allow_unknown_fields = true` in Python or `setAllowUnknownFields(true)` in Java.",
      "success_rate": 0.8,
      "how": "Use protobuf's `allow_unknown` field option in the server code to ignore unknown enum values: `options.allow_unknown_fields = true` in Python or `setAllowUnknownFields(true)` in Java.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保客户端和服务器使用相同的 .proto 文件版本：在两端运行 `protoc --version`，并使用相同的模式重新编译。",
    "在 proto 定义中添加一个回退枚举值（如 'UNKNOWN'，值为 0）以优雅处理未知值：`enum Status { UNKNOWN = 0; ... }`",
    "在服务器代码中使用 protobuf 的 `allow_unknown` 字段选项忽略未知枚举值：在 Python 中设置 `options.allow_unknown_fields = true`，或在 Java 中设置 `setAllowUnknownFields(true)`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://protobuf.dev/programming-guides/enum/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-03-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}