Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Mesosphere Sprint 64, Mesosphere Sprint 65
-
3
Description
To use protobuf enum in a backwards compatible way, the suggestion on the protobuf mailing list is to use optional enum fields and include an UNKNOWN value as the first entry in the enum list (and/or explicitly specifying it as the default). This can handle the case of parsing protobuf message from a serialized string, but it can not handle the case of parsing protobuf message from JSON.
E.g., when I access master endpoint with an inexistent enum xxx, I will get an error:
$ curl -X POST -H "Content-Type: application/json" -d '{"type": "xxx"}' 127.0.0.1:5050/api/v1 Failed to convert JSON into Call protobuf: Failed to find enum for 'xxx'%
In the Call protobuf message, the enum Type already has a default value UNKNOWN (see here for details) and the field Call.type is optional, but the above curl command will still fail. The root cause is, in the code here when we try to get the enum value for the string "xxx", it will fail since there is no any enum value corresponding to "xxx".