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

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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

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

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Changing field type requires proto regeneration and may break compatibility.

  2. 100% fail

    The marshaling will fail and the RPC will not complete.