Skip to content

ServerToAgentCommand.CommadType zero value is "restart" #361

Description

@domodwyer

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:

  1. A client is running happily.
  2. The protobuf spec is updated, adding a new command to the protocol: CommandType:Bananas
  3. The OpAMP server is updated to support this new command.
  4. For whatever reason, the server sends CommandType::Bananas to the client running an old version of the spec.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions