Currently the CommandType enum has no "unspecified" catch all field - the "zero value" of the enum is Restart:
|
enum CommandType { |
|
// The Agent should restart. This request will be ignored if the Agent does not |
|
// support restart. |
|
CommandType_Restart = 0; |
|
} |
Because the protobuf wire format is designed to be backwards compatible, it is generally considered good practice to map the zero value to some sentinel "unknown" / "unspecified" indicator as it prevents this scenario:
- A client is running happily.
- The protobuf spec is updated, adding a new command to the protocol:
CommandType:Bananas
- The OpAMP server is updated to support this new command.
- For whatever reason, the server sends
CommandType::Bananas to the client running an old version of the spec.
- The client restarts because it doesn't recognise the
Bananas command, and so maps it to the "zero value" which is CommandType::Restart.
Changing the zero value would be a breaking change, but defaulting the zero value to "restart" is a bit of a dangerous default, so might be worth considering a remap before taking this enum out of beta.
Most enums have the "unspecified" zero mapping already, but a couple are missing them - it might also be worth considering a protobuf linter to help catch this in the future - I'd be happy to submit a PR to add one.
Currently the
CommandTypeenum has no "unspecified" catch all field - the "zero value" of the enum isRestart:opamp-spec/proto/opamp/v1/opamp.proto
Lines 681 to 685 in 42f0187
Because the protobuf wire format is designed to be backwards compatible, it is generally considered good practice to map the zero value to some sentinel "unknown" / "unspecified" indicator as it prevents this scenario:
CommandType:BananasCommandType::Bananasto the client running an old version of the spec.Bananascommand, and so maps it to the "zero value" which isCommandType::Restart.Changing the zero value would be a breaking change, but defaulting the zero value to "restart" is a bit of a dangerous default, so might be worth considering a remap before taking this enum out of beta.
Most enums have the "unspecified" zero mapping already, but a couple are missing them - it might also be worth considering a protobuf linter to help catch this in the future - I'd be happy to submit a PR to add one.