-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snake case protobuf enums fail to compile. #2776
Comments
Hi, thanks for your issue! Is this a problem with lower cased enum values specifically? I've never seen anyone use anything but |
@johanbrandhorst that's undestandable. The probelm is with the enum itself, not the values.
Let me include the proto file here. api.proto
|
I'll include the remaining text files just in case you decide to repro using the docker image, so you don't have to untar anything: repro.go
entrypoint.sh
Dockerfile
|
Thanks for adding those files :). This should be pretty easy to reproduce in our own repository by adding an ugly looking enum to one of our example Protobuf files, e.g. https://github.com/grpc-ecosystem/grpc-gateway/blob/master/examples/internal/proto/examplepb/a_bit_of_everything.proto. Then rerunning generation should reproduce the error. From there, we'll have to fix it or our build won't succeed. Would you be interested in trying to fix this? |
I'm interested, but unfortunately can't afford to spend the time on it at
the moment.
Whenever some time frees up, I'll take a stab at it if it's still open.
Can't commit to it, though.
…On Wed, Jun 29, 2022 at 1:20 PM Johan Brandhorst-Satzkorn < ***@***.***> wrote:
Thanks for adding those files :). This should be pretty easy to reproduce
in our own repository by adding an ugly looking enum to one of our example
Protobuf files, e.g.
https://github.com/grpc-ecosystem/grpc-gateway/blob/master/examples/internal/proto/examplepb/a_bit_of_everything.proto.
Then rerunning generation should reproduce the error. From there, we'll
have to fix it or our build won't succeed. Would you be interested in
trying to fix this?
—
Reply to this email directly, view it on GitHub
<#2776 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANPP3F7FJ6NPLRH7H53253VRSHYBANCNFSM52GBA2VA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'm interested in trying to fix this. TL; DRI've been able to reproduce the issue, looks like identifiers for enums in the Reproducing the issueI was able to reproduce the issue as well by:
Enums and service added to
InvestigationSo far, looks like the proto generator
While the grpc-gateway proto generator
Causing the derived enum identifiers in the Identifiers mismatch summary:
Fix proposalI suspect the fix is to apply the Camel-casing function to the enum names as is done for the service and method names in the applyTemplate function. But in this case, the difference is that looping through the service and methods' names (+ casing) is done in the code, while looping through the enum's names is done within the template. Could you point if I'm in the right direction and hint a path for the fix? |
Hi @jbaxx, thanks for that thorough analysis! I think you're already well on the way there, adding a failing example to |
@johanbrandhorst are there any plans to put out a release with this bug fix in the short term? |
I've just tagged v2.11.3: https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v2.11.3 |
@johanbrandhorst Output:
|
It can take a few hours for the Go proxy to pick up a new version, I just ran the command you pasted here locally and it worked fine for me! Let me know if it's still not working. |
I just ran it and still the same |
@johanbrandhorst FYI, for whatever reason, after cleaning the contents of |
🐛 Bug Report
When declaring snake cased enums in a proto file, grpc-gateway fails to render the correct go type name for it, writing the type name as-is instead of converting to camel case.
GRPC correctly uses property
GoIdent
ofprotogen.Enum
to produce the proper type name.To Reproduce
what
typed with said enumwhat
member is part of the REST URL (e.g.:/api/{what}
)A minimal repro is available as a docker image source in repro.tar.gz. To reproduce, run:
Contents of the attached archive:
Expected behavior
The source file generated by the grpc-gateway plugin should compile successfully.
Actual Behavior
Compilation fails:
Your Environment
An isolated Debian-based container with go 1.18.
The text was updated successfully, but these errors were encountered: