go
build_error
ai_generated
true
panic: proto: duplicate field number 5 in message pb.User
ID: go/protobuf-duplicate-field-number
80%Fix Rate
89%Confidence
0Evidence
2025-01-09First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.x | active | — | — | — |
Root Cause
Two fields in the same message share a field number, which protobuf forbids. This usually arises from hand-editing generated code or merging conflicting .proto definitions.
generic中文
同一消息中的两个字段共享相同的字段编号,protobuf 禁止此行为。通常由手工编辑生成代码或合并冲突的 .proto 定义引起。
Workarounds
-
95% success
Assign a unique field number to each field in the .proto, then regenerate with protoc --go_out=. --go-grpc_out=. and never hand-edit generated files.
-
90% success
Use reserved field numbers to prevent reuse: reserved 5; when removing a field, and run buf lint to catch duplicate numbers at build time.
Dead Ends
Common approaches that don't work:
-
95% fail
The duplicate numbering corrupts wire format; removing the check produces silent data corruption instead of a clear failure.
-
90% fail
The number, not the name, is what must be unique; the panic persists.