go type_error ai_generated true

rpc error: code = Internal desc = grpc: error while unmarshaling: proto: cannot parse invalid wire-format data

ID: go/grpc-internal-error-codec-mismatch

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.0 active — — —
1.1 active — — —

Root Cause

The server received data that is not valid protobuf, often due to codec mismatch or data corruption.

generic

中文

服务器接收到无效的protobuf数据,通常是由于编解码器不匹配或数据损坏。

Workarounds

  1. 90% success Ensure both client and server use the same protobuf version and schema.
    Run 'protoc --go_out=. --go-grpc_out=. *.proto' on both sides and rebuild.
  2. 70% success Add logging to inspect the raw bytes received.
    Use a server interceptor to log incoming data for debugging:
    func loggingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
        log.Printf("request: %v", req)
        return handler(ctx, req)
    }

Dead Ends

Common approaches that don't work:

  1. Assume the data is fine and retry. 100% fail

    If the data is malformed, retrying will produce the same error.

  2. Change the protobuf schema without regenerating code. 95% fail

    The server and client must use the same schema; manual changes cause incompatibility.