Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: Issue decoding wrapped values after upgrading from 3.10.1 to 3.11.1 #7029

Closed
makushline opened this issue Dec 18, 2019 · 1 comment · Fixed by #7195
Closed

Ruby: Issue decoding wrapped values after upgrading from 3.10.1 to 3.11.1 #7029

makushline opened this issue Dec 18, 2019 · 1 comment · Fixed by #7195

Comments

@makushline
Copy link

makushline commented Dec 18, 2019

$ cat repo.rb
require 'google/protobuf'
require 'google/protobuf/wrappers_pb'
Google::Protobuf::DescriptorPool.generated_pool.build do
  add_message "Person" do
    optional :name, :message, 1, "google.protobuf.StringValue"
  end
end
Person  = Google::Protobuf::DescriptorPool.generated_pool.lookup("Person").msgclass
puts "before decoding"
puts hi = Person.new(:name => {:value => "hi"})
puts empty = Person.new(:name => {:value => ""})
puts not_set = Person.new()
puts "after decoding"
puts Person.decode(hi.to_proto)
puts Person.decode(empty.to_proto)
puts Person.decode(not_set.to_proto)

// at google-protobuf 3.11.0
$ ruby repo.rb 
before decoding
<Person: name: <Google::Protobuf::StringValue: value: "hi">>
<Person: name: <Google::Protobuf::StringValue: value: "">>
<Person: name: nil>
after decoding
<Person: name: <Google::Protobuf::StringValue: value: "hi">>
<Person: name: nil>
<Person: name: nil>

// at google-protobuf 3.10.1
$ ruby repo.rb
before decoding
<Person: name: <Google::Protobuf::StringValue: value: "hi">>
<Person: name: <Google::Protobuf::StringValue: value: "">>
<Person: name: nil>
after decoding
<Person: name: <Google::Protobuf::StringValue: value: "hi">>
<Person: name: <Google::Protobuf::StringValue: value: "">>
<Person: name: nil>

$ cat Gemfile.lock
source "https://rubygems.org"
gem "google-protobuf", "3.10.1"

I expect the decoded Person with an empty name to look like
<Person: name: <Google::Protobuf::StringValue: value: "">>

@haberman
Copy link
Member

Could you try this PR and verify that it fixes your problem?

#7195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants