# 错误：proto：无法解析无效的线格式数据

- **ID:** `go/grpc-protobuf-unmarshal-field-mismatch`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

通过gRPC接收的protobuf消息包含一个具有意外线类型的字段，通常是由于客户端和服务器之间的模式不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## 解决方案

1. **Regenerate Go protobuf code from the same .proto file on both sides.** (95% 成功率)
   ```
   protoc --go_out=. --go-grpc_out=. *.proto
   ```
2. **Use protojson format for debugging to identify field type mismatches.** (80% 成功率)
   ```
   import "google.golang.org/protobuf/encoding/protojson"
b, _ := protojson.Marshal(msg)
log.Printf("%s", b)
   ```

## 无效尝试

- **Restart both client and server without checking proto files.** — The issue is structural mismatch, not transient state. (90% 失败率)
- **Update only the client binary without regenerating proto code.** — Stale generated code still has old field definitions. (85% 失败率)
