# rpc错误：代码=内部 描述=grpc：编组时出错：proto：字段标签不匹配

- **ID:** `go/grpc-internal-error-proto-mismatch`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

客户端和服务器使用的protobuf定义不同步（例如不同的字段编号或类型），导致编组/解组失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.22 | active | — | — |
| 1.23 | active | — | — |

## 解决方案

1. **Regenerate protobuf stubs from the same .proto file for both client and server.** (95% 成功率)
   ```
   protoc --go_out=. --go-grpc_out=. *.proto
# ensure same .proto version is used everywhere
   ```
2. **Use buf tool to enforce proto compatibility checks.** (90% 成功率)
   ```
   buf breaking --against '.git#branch=main'
   ```

## 无效尝试

- **Clearing the client cache and retrying.** — The proto definitions are still mismatched; cache is irrelevant. (95% 失败率)
- **Manually editing the generated .pb.go files.** — Files are auto-generated; manual edits break regeneration. (90% 失败率)
