Re: [protobuf] Re: Message missing required fields exception when parsing a message that has required fields defaulted
On Wed, Oct 27, 2010 at 8:55 AM, locky wrote: > The producers of the message are actually C# and not C++ as I first > mentioned (I only deal with the Java implementation). The scenario > however, is the same. > It is possible that the C# implementation (which is not written by Google) accidentally interpreted default values differently. You should ask the author. > @Kenton, I thought default values were never sent over the wire. > According to the 'Updating A Message Type' section of the language > guide ..."Changing a default value is generally OK, as long as you > remember that default values are never sent over the wire" > > Are you saying this is not the case? > What the documentation means is that the value you write in the .proto file is never used directly when serializing a message. However, if you explicitly set a field to a value that happens to be equal to the default value, it *is* sent. In this case we don't think of the value as being the default value. Seems like the wording of that text needs to be improved to avoid ambiguity. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Re: Message missing required fields exception when parsing a message that has required fields defaulted
On Oct 26, 2010, at 4:13 , locky wrote: The C++ side is setting things correctly. My understanding is that default values are not sent over the wire. When building a received message from a byte[ ] a check is done to see if required fields have been set. Any required field that was not sent due to having a default value on the other side is not marked as being set and the exception gets thrown. This is exactly correct. You should do two things: 1. Set this field on the sending side, but you mentioned that you are already doing this. 2. Verify that the bytes you are reading in on one side match the bytes being sent. I usually get this error when there is some sort of message handling error. For example, if you pass protobuf an empty array, you'll get this error message. You should write out the bytes that you are writing, and the bytes that you are reading and verify that they match. Also verify that the size you are passing in matches. There is a difference between an unset field with a default value of "" and a set field with a value of "". The .hasProperty() method will return true for the set field, and false for the unset field. Thus, these messages are serialized differently. Hope this helps, Evan -- Evan Jones http://evanjones.ca/ -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.