# rpc 错误：代码 = Internal 描述 = grpc：编组时出错：字符串字段包含无效的 UTF-8

- **ID:** `go/grpc-invalid-header`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

proto 消息中的字符串字段包含无效的 UTF-8 字节，违反了 proto3 字符串要求。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   req.Name = strings.ToValidUTF8(req.Name, "")
   ```
2. **** (50% 成功率)
   ```
   marshaler := protojson.MarshalOptions{EmitUnpopulated: true}; data, _ := marshaler.Marshal(msg)
   ```

## 无效尝试

- **** — Changing field type requires proto regeneration and may break compatibility. (60% 失败率)
- **** — The marshaling will fail and the RPC will not complete. (100% 失败率)
