go
data_error
ai_generated
true
rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8
ID: go/grpc-invalid-header
80%Fix Rate
85%Confidence
0Evidence
2024-11-11First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.11 | active | — | — | — |
Root Cause
A string field in the proto message contains invalid UTF-8 bytes, which violates proto3 string requirements.
generic中文
proto 消息中的字符串字段包含无效的 UTF-8 字节,违反了 proto3 字符串要求。
Workarounds
-
90% success
req.Name = strings.ToValidUTF8(req.Name, "")
-
50% success
marshaler := protojson.MarshalOptions{EmitUnpopulated: true}; data, _ := marshaler.Marshal(msg)
Dead Ends
Common approaches that don't work:
-
60% fail
Changing field type requires proto regeneration and may break compatibility.
-
100% fail
The marshaling will fail and the RPC will not complete.