Exception serializing message

Viewed 2918

I am using a stream of message request in grpc as following:

def Post(self, request_iterator, context):
        print("Post")
        for request in request_iterator:
            print("Request")
            if hasattr(request , "type"):
                print("Has type")

With the following proto:

syntax ="proto3";

package nbsb;

message SDF {
    Thing thing = 1;
    repeated Object objects = 2;
    string type = 3;
}

message Property {
    string name = 1;
    string value = 2;
}
message Thing {
    string id = 1;
    string name = 2;
}
message Object {
    repeated string idObject = 1;
    string name = 2;
    repeated Property properties = 3;
}

message Response {
    repeated string id = 1;
    string value = 2;
}

service Connector{
    rpc Get(SDF) returns (Response){}
    rpc Put(SDF) returns (Response){}
    rpc Post(stream SDF) returns (stream SDF){}
}

The desired output should be a right serialization and de-serialization of messages. The output is the following:

Post
<grpc._server._RequestIterator object at 0x000002CA1CFE5100>
ERROR:grpc._common:Exception serializing message!
Traceback (most recent call last):
  File "C:\Python\Python3\lib\site-packages\grpc\_common.py", line 83, in _transform
    return transformer(message)
  File "C:\Python\Python3\lib\site-packages\google\protobuf\internal\python_message.py", line 1082, in SerializeToString
    if not self.IsInitialized():
AttributeError: 'NoneType' object has no attribute 'IsInitialized'

Can someone help me solving or understanding why it is happening?

1 Answers

It seems None is returned from the gRPC library, there could be a silent exception. If you are familiar with pdb, can you try to find the source of the None message? Or, you can turn on tracing log by specify environment variable GRPC_TRACE=all GRPC_VERBOSITY=debug, see doc.

If the problem persists, please consider report it to https://github.com/grpc/grpc/issues with a reproduction snippet.

Related