Infer type of protobuf Any value in Ruby

Viewed 108

I have a value which is of type Google::Protobuf::Any. I want to unpack it by doing something like below:

 any_value = Google::Protobuf::Any.new(
          type_url: 'type.googleapis.com/google.protobuf.Int64Value',
          value:    '1'
        )
 type = Google::Protobuf::DescriptorPool.generated_pool.lookup(any_value.type_name)
 value = any_value.unpack(type)

Unfortunately, the type always comes back as nil, leading to an error:

NoMethodError:
       undefined method `descriptor' for nil:NilClass

any_value.type_name is not nil. When I print it out, it is:

google.protobuf.Int64Value

What am I doing wrong?

0 Answers
Related