0

Hi I am using gRPC Ruby plugin to communicate to a service. The proto definition contains(proto3):

uint32 id = 1;

But, when I assign nil to id, it throws an error - expected number for integral field. But for strings, nil values work fine. How do I allow nil values for integral / float fields?

shiladitya
  • 2,290
  • 1
  • 23
  • 36

1 Answers1

0

The default values for strings in proto3 is empty - https://github.com/google/protobuf/issues/359

Hence it can receive the nil value without returning an error, Integers on the other hand have default values set to 0. Try passing 0 in case you do not want to pass any value.

Suggestion: - In case you do not wish to pass any tuples for a message written in proto3 you can leave the message blank which is a very valid way to define a message.

For Instance:-

syntax="proto3"
service Foo{
            rpc Index(Empty) Returns(Nothing){}
            }
message Empty{}
message Nothing{}
susheel
  • 36
  • 6