diff --git a/interceptors/protovalidate/protovalidate.go b/interceptors/protovalidate/protovalidate.go index 7072b949..84f8e1d9 100644 --- a/interceptors/protovalidate/protovalidate.go +++ b/interceptors/protovalidate/protovalidate.go @@ -68,7 +68,7 @@ func (w *wrappedServerStream) RecvMsg(m interface{}) error { func validateMsg(m interface{}, validator *protovalidate.Validator, opts *options) error { msg, ok := m.(proto.Message) if !ok { - return errors.New("unsupported message type") + return status.Errorf(codes.Internal, "unsupported message type: %T", m) } if opts.shouldIgnoreMessage(msg.ProtoReflect().Descriptor().FullName()) { return nil diff --git a/interceptors/protovalidate/protovalidate_test.go b/interceptors/protovalidate/protovalidate_test.go index b8798441..dcc2c8f7 100644 --- a/interceptors/protovalidate/protovalidate_test.go +++ b/interceptors/protovalidate/protovalidate_test.go @@ -53,8 +53,8 @@ func TestUnaryServerInterceptor(t *testing.T) { t.Run("not_protobuf", func(t *testing.T) { _, err = interceptor(context.Background(), "not protobuf", info, handler) - assert.Error(t, err) - assert.Equal(t, codes.Unknown, status.Code(err)) + assert.EqualError(t, err, "rpc error: code = Internal desc = unsupported message type: string") + assert.Equal(t, codes.Internal, status.Code(err)) }) interceptor = protovalidate_middleware.UnaryServerInterceptor(validator,