go data_error ai_generated true

proto: duplicate field "name" in JSON

ID: go/protobuf-json-marshal-duplicate-field

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-06-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active — — —

Root Cause

The JSON input contains the same field more than once, which protojson rejects.

generic

中文

JSON 输入中同一字段出现多次,protojson 拒绝解析。

Workarounds

  1. 90% success
    // Validate JSON before sending; use a library that enforces uniqueness.
  2. 85% success
    opts := protojson.UnmarshalOptions{DiscardUnknown: true}
    err := opts.Unmarshal(data, msg)

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Lenient parsers may not handle protobuf semantics correctly.

  2. 70% fail

    Manual removal is error-prone and not scalable.