{
  "id": "data/protobuf-field-number-collision",
  "signature": "Protobuf deserialization produces wrong values when field numbers are reused across different message types",
  "signature_zh": "当字段编号在不同消息类型之间重复使用时，Protobuf反序列化产生错误值",
  "regex": "Protobuf.*field.*number.*collision|field number.*reuse|protobuf.*deserialization.*wrong value",
  "domain": "data",
  "category": "serialization_error",
  "subcategory": null,
  "root_cause": "Protobuf wire format uses field numbers only, not names, so reusing field numbers across different message types in the same file can cause field values to be assigned to the wrong fields during deserialization.",
  "root_cause_type": "generic",
  "root_cause_zh": "Protobuf线格式仅使用字段编号，而非名称，因此在同一文件中跨不同消息类型重复使用字段编号可能导致反序列化期间字段值被分配给错误的字段。",
  "versions": [
    {
      "version": "Protocol Buffers 3.21.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "protoc 24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC 1.57.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding deprecated annotations to conflicting fields",
      "why_fails": "Adding fields with new numbers does not fix the existing field number collision issue.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using 'reserved' keyword for conflicting field numbers",
      "why_fails": "Reserved prevents new use but does not fix existing serialized data with wrong field numbers.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all message types use unique field numbers across the entire .proto file: message User { int32 id = 1; } message Product { int32 product_id = 1; } // Change to use distinct numbers",
      "success_rate": 0.95,
      "how": "Ensure all message types use unique field numbers across the entire .proto file: message User { int32 id = 1; } message Product { int32 product_id = 1; } // Change to use distinct numbers",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a migration script to rewrite existing serialized data with corrected field numbers: for each message, decode using old schema, then re-encode with new schema mapping old field numbers to new ones",
      "success_rate": 0.85,
      "how": "Use a migration script to rewrite existing serialized data with corrected field numbers: for each message, decode using old schema, then re-encode with new schema mapping old field numbers to new ones",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure all message types use unique field numbers across the entire .proto file: message User { int32 id = 1; } message Product { int32 product_id = 1; } // Change to use distinct numbers",
    "Use a migration script to rewrite existing serialized data with corrected field numbers: for each message, decode using old schema, then re-encode with new schema mapping old field numbers to new ones"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://protobuf.dev/programming-guides/encoding/#fields",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-09-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}