# panic: proto: 字段 pb.User.labels 包含无效的 nil map 值

- **ID:** `go/protobuf-marshal-nil-map`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

proto map 字段被赋值为包含 nil 值的 map（如 map[string]*Meta{"k": nil}），protobuf 运行时在序列化时拒绝该值。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| google.golang.org/protobuf 1.x | active | — | — |

## 解决方案

1. **** (92% 成功率)
   ```
   labels := make(map[string]*pb.Meta)
for k, v := range src {
  if v == nil { continue }
  labels[k] = v
}
msg.Labels = labels
   ```
2. **** (88% 成功率)
   ```
   // user.proto
message User {
  map<string, Meta> labels = 1;
}
   ```

## 无效尝试

- **** — Swallowing the panic leaves the message unsent and corrupts control flow. (85% 失败率)
- **** — Data loss and hidden bugs; the caller has no signal that data was dropped. (70% 失败率)
