# proto: （第 1 行第 15 列）：未知字段 "userName"

- **ID:** `go/proto-json-unknown-field`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

protojson.Unmarshal 遇到与消息中任何字段都不匹配的 JSON 键。默认情况下 protojson 拒绝未知字段，且对 proto 字段名大小写敏感（接受 camelCase 或 snake_case）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| google.golang.org/protobuf v1.30+ | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   opts := protojson.UnmarshalOptions{DiscardUnknown: true}
err := opts.Unmarshal(data, msg)
   ```
2. **** (85% 成功率)
   ```
   // user.proto
string user_name = 1 [json_name = "userName"];
   ```

## 无效尝试

- **** — Field renames change the wire contract and require regenerating all clients; it treats a symptom, not the schema mismatch. (60% 失败率)
- **** — protojson returns an error and leaves the message partially populated or empty; downstream reads wrong data. (85% 失败率)
