go data_error ai_generated true

rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8

ID: go/grpc-internal-status-details

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-08-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active

Root Cause

A protobuf string field contains bytes that are not valid UTF-8. Protobuf strings must be valid UTF-8; otherwise, marshaling fails.

generic

中文

protobuf 字符串字段包含不是有效 UTF-8 的字节。protobuf 字符串必须是有效的 UTF-8;否则序列化会失败。

Workarounds

  1. 90% success
    s = strings.ToValidUTF8(s, "")
  2. 85% success
    Use utf8.ValidString(s) to check before sending.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    This changes the API contract and may break compatibility.

  2. 70% fail

    This corrupts the data and may not be acceptable.