Ruby protobuf message cannot be converted to hash if it uses map<...> fields.
Probably, because of https://github.com/google/protobuf/blob/master/ruby/ext/google/protobuf_c/message.c#L371
Gem version:
gem 'google-protobuf', '3.0.0.alpha.5.0.5.1'
Proto:
// compile:
// protoc --ruby_out=. xxx.proto
syntax = "proto3";
package xxx;
message WithMap {
map<string,string> map = 1;
}
Compiled proto:
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: xxx.proto
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "xxx.WithMap" do
map :map, :string, :string, 1
end
end
module Xxx
WithMap = Google::Protobuf::DescriptorPool.generated_pool.lookup("xxx.WithMap").msgclass
end
This fails:
require_relative 'xxx'
p Xxx::WithMap.new.to_h
With:
debug.rb:3:in `to_h': wrong argument type Google::Protobuf::Map (expected Google::Protobuf::RepeatedField) (TypeError)
from debug.rb:3:in `<main>'
Seems to be resolved in https://github.com/google/protobuf/pull/396 , but still not merged.
I am also experiencing this issue; is there any expectation that this will be fixed in the near future? I would offer to try and patch it myself, but it looks like there's an outstanding PR that fixes it already there. Is there something I can do to help move it along?
Agreed-- what can be done here to get this fix in?
Wow, sorry this bug went unfixed for so long. I've assigned it to myself now.
Most helpful comment
Wow, sorry this bug went unfixed for so long. I've assigned it to myself now.