go
data_error
ai_generated
true
rpc 错误:代码 = Internal 描述 = grpc:序列化时出错:字符串字段包含无效的 UTF-8
rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8
ID: go/grpc-internal-status-details
80%修复率
85%置信度
0证据数
2024-08-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.x | active | — | — | — |
根因分析
protobuf 字符串字段包含不是有效 UTF-8 的字节。protobuf 字符串必须是有效的 UTF-8;否则序列化会失败。
English
A protobuf string field contains bytes that are not valid UTF-8. Protobuf strings must be valid UTF-8; otherwise, marshaling fails.
解决方案
-
90% 成功率
s = strings.ToValidUTF8(s, "")
-
85% 成功率
Use utf8.ValidString(s) to check before sending.
无效尝试
常见但无效的做法:
-
60% 失败
This changes the API contract and may break compatibility.
-
70% 失败
This corrupts the data and may not be acceptable.