Hello,
I have been using a naming convention for Protobuf enums, where I would prefix the enum values with the enum type name in order to avoid enum value name collisions.
E.g.
enum FooBar {
FOO_BAR_UNSPECIFIED = 0;
FOO_BAR_FIRST_VALUE = 1;
FOO_BAR_SECOND_VALUE = 2;
}
The compiled code (e.g. protoc c#) would handle this nicely by dropping the prefixes matching the enum name, so I would get nice value names: Unspecified, FirstValue, SecondValue. And it still does this today.
However, the HTTP/JSON to GRPC transcoder has changed the way it works.
When issuing an HTTP/JSON request against endpoints, it used to accept the enum string values without the enum type name prefix (e.g. "UNSPECIFIED", "FIRST_VALUE"), but today it no longer does that, it only accepts the full values (e.g. "FOO_BAR_UNSPECIFIED", "FOO_BAR_FIRST_VALUE").
I have tried several versions - I see the old behaviour is present in version 1.34.0, but it is broken in version 1.35.0 and up.
Is this a bug and the old behaviour work in the future?
Or is this the way it is going to be from now on, so should I change my implementation?
One more time - this used to work, but does not work any more:
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"FooBar": "FIRST_VALUE"
}'
But today it gives me an exception:
INVALID_ARGUMENT: FooBar: invalid value "FIRST_VALUE" for type TYPE_ENUM"
I need to change the payload to make it work:
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"FooBar": "FOO_BAR_FIRST_VALUE"
}'