2

Is it (practically) possible to change the type name of a protobuf message type (or enum) without breaking communications?

Obviously the using code would need to be adpated to re-compile. The question is if old clients that use the same structure, but the old names, would continue to work?

Example, base on the real file:

test.proto:

syntax = "proto3";
package test;
// ...

message TestMsgA {

  message TestMsgB { // should be called TestMsgZZZ going forward
    // ...
    enum TestMsgBEnum { // should be called TestMsgZZZEnum going forward
    // ...
    }

    TestMsgBEnum foo = 1;
    // ...
  }

  repeated TestMsgB bar = 1;
  // ...
}

Does the on-the-wire format of the protobuf payload change in any way if type or enum names are changed?

Martin Ba
  • 37,187
  • 33
  • 183
  • 337

1 Answers1

2

If you're talking about the binary format, then no: names don't matter and will not impact your ability to load data; For enums, only the integer value is stored in the payload. For fields, only the field-number is stored.

Obviously if you swap two names, confusion could happen, but: it should load as long as the structure matches.

If you're talking about the JSON format, then it may matter.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • 1
    With "may matter", do you mean to say that the proto3 [JsonParser](https://github.com/protocolbuffers/protobuf/blob/master/csharp/src/Google.Protobuf/JsonParser.cs) might be affected, or just that the json-serialzed form of the messages will be different? – Martin Ba Nov 12 '19 at 11:45