# INVALID_ARGUMENT: 消息类型 google.protobuf.Timestamp 中存在未知字段42

- **ID:** `grpc/protobuf-unknown-field-rejected`
- **领域:** grpc
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

启用protobuf严格验证（如'protojson.DiscardUnknown=false'或gRPC-Web）的gRPC服务器拒绝包含protobuf消息中未知字段编号的请求。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| protobuf v25.0 | active | — | — |
| gRPC v1.64.0 | active | — | — |
| gRPC-Web v1.5.0 | active | — | — |

## 解决方案

1. ```
   更新客户端以移除未知字段：在protobuf JSON中，从请求负载中省略字段42；对于gRPC-Web，通过从相同.proto文件重新生成存根，确保protobuf二进制文件不包含额外字段。
   ```
2. ```
   更新服务器以接受未知字段：将字段42添加到protobuf定义并重新生成服务器代码；部署更新的服务器二进制文件以匹配客户端架构。
   ```
3. ```
   使用自定义protobuf解析器，在Go中设置'protojson.UnmarshalOptions{DiscardUnknown: true}'或其他语言中的等效选项，以忽略服务器端的未知字段，但需记录风险。
   ```

## 无效尝试

- **** — Adding a new field to the protobuf definition without updating the server binary fails because the server still lacks the field descriptor. (90% 失败率)
- **** — Ignoring the error and retrying the same request repeatedly doesn't change the server's validation; the error persists until the unknown field is removed. (99% 失败率)
- **** — Disabling server-side validation entirely ('protojson.DiscardUnknown=true') may expose the server to malicious payloads or data corruption from future schema changes. (60% 失败率)
