go
data_error
ai_generated
true
proto: JSON 中字段 "name" 重复
proto: duplicate field "name" in JSON
ID: go/protobuf-json-marshal-duplicate-field
80%修复率
85%置信度
0证据数
2025-06-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.x | active | — | — | — |
根因分析
JSON 输入中同一字段出现多次,protojson 拒绝解析。
English
The JSON input contains the same field more than once, which protojson rejects.
解决方案
-
90% 成功率
// Validate JSON before sending; use a library that enforces uniqueness.
-
85% 成功率
opts := protojson.UnmarshalOptions{DiscardUnknown: true} err := opts.Unmarshal(data, msg)
无效尝试
常见但无效的做法:
-
80% 失败
Lenient parsers may not handle protobuf semantics correctly.
-
70% 失败
Manual removal is error-prone and not scalable.