go-kratos/kratos · error
failed to unmarshal, message is %T, want proto.Message
Error message
failed to unmarshal, message is %T, want proto.Message
What it means
Error "failed to unmarshal, message is %T, want proto.Message" thrown in go-kratos/kratos.
Source
Thrown at transport/grpc/codec.go:33
func init() {
encoding.RegisterCodec(codec{})
}
// codec is a Codec implementation with protobuf. It is the default codec for gRPC.
type codec struct{}
func (codec) Marshal(v any) ([]byte, error) {
vv, ok := v.(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
}
return enc.GetCodec(protojson.Name).Marshal(vv)
}
func (codec) Unmarshal(data []byte, v any) error {
vv, ok := v.(proto.Message)
if !ok {
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
}
return enc.GetCodec(protojson.Name).Unmarshal(data, vv)
}
func (codec) Name() string {
return jsonName
}
View on GitHub (pinned to 668db92c2c)
When it happens
Trigger: Thrown at transport/grpc/codec.go:33 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/e30b562fa8130c8b.
Report an issue: GitHub.