Is Resulting Binary from Changing Proto Definition Source (From Nested to Non-Nested) for Fields initialization Backward-Compatible?

39 views
Skip to first unread message

Felik

unread,
Apr 20, 2023, 2:00:38 AM4/20/23
to Protocol Buffers
Hello,

I came to understand that the binary serialization only concern of field identifiying number (hence renaming field and message is backward compatible).

I would like to confirm my understanding if following case is also backward compatible (I could not find any resource that discuss about this, or I may have used the incorrect search term for this).

Let's say previously I have defined a nested proto definition as follow:

message OuterProto {
   message InnerProto {
      optional bool field_bool = 1;
      optional int64 field_int = 2;
   }

   optional InnerProto field_composed = 1;
}

Now, I would like to "un-nest" the InnerProto definition by redefining another duplicate proto in top level as follow:

// same exact field numbering & type
message NewInnerAsTopLevelProto {
      optional bool field_bool = 1;
      optional int64 field_int = 2;
}

Would following modification to message OuterProto be backward-compatible ?

message OuterProto {
   message InnerProto {    // unused
      optional bool field_bool = 1;
      optional int64 field_int = 2;
   }

   optional NewInnerAsTopLevelProto field_composed = 1;
}

Any input & insight would be much appreciated. Thank you!

Marc Gravell

unread,
Apr 20, 2023, 2:49:17 AM4/20/23
to Felik, Protocol Buffers
As long as you aren't using `Any`: then at the binary payload data it won't be visible. Any existing code that uses the generated types will need to be updated, obviously.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/40a99e57-b80e-4bff-bf41-0622046ec12fn%40googlegroups.com.

Timo

unread,
Apr 20, 2023, 9:25:24 AM4/20/23
to Protocol Buffers
google.protobuf.Any stores the qualified name of the packed message as a string. It is only a breaking change if InnerProto was stored in Any, not if OuterProto was stored. 
Reply all
Reply to author
Forward
0 new messages