Enum naming convention is broken after version 1.35.0 (HTTP/JSON to GRPC transcoder)

306 views
Skip to first unread message

al...@viggo.io

unread,
Aug 1, 2019, 7:41:43 AM8/1/19
to Google Cloud Endpoints
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"
}'








qiwz...@google.com

unread,
Aug 8, 2019, 8:44:43 PM8/8/19
to Google Cloud Endpoints
We are using grpc to do the transcoding.   ESP 1.35.0 has upgraded grpc to 1.21.  It may have changed the behaviors.  So you should change your code.

Thanks
-Wayne
Reply all
Reply to author
Forward
0 new messages