Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated files contain calls to methods that don't exist #1643

Closed
catper opened this issue Sep 3, 2020 · 1 comment
Closed

Generated files contain calls to methods that don't exist #1643

catper opened this issue Sep 3, 2020 · 1 comment

Comments

@catper
Copy link

catper commented Sep 3, 2020

馃悰 Bug Report

Some of the .pb.go files that get generated contain calls to methods in other generated files, but said methods don't actually exist.

To Reproduce

I'm afraid this is going to be a terrible bug report since I'm unable to share any of the files that I'm working with but we'll see. I'm not sure where this issue stems from and if the problem lies in grpc-gateway or elsewhere but here's an attempt at describing what happens.

I have a proto at path ~/dev/services/my-org/my-service/v1/my_service.proto. The proto package is package my-org.my-service.v1; and I've declared option go_package = "my-org.com/rest-proxy/my-service/v1"

The proto includes an import of another proto ("other.proto") which is located in the same folder as the service proto.

From inside ~/dev/services/my-org I execute the following commands for both protos:

protoc -I$PROTO_INCLUDE  --go_out=paths=source_relative:my-org/my-service/gen/grpc-gateway/src/gen $PROTO
protoc -I$PROTO_INCLUDE --go-grpc_out=paths=source_relative:my-org/my-service/gen/grpc-gateway/src/gen $PROTO
protoc -I$PROTO_INCLUDE  --grpc-gateway_out=paths=source_relative,logtostderr=true:my-org/my-service/gen/grpc-gateway/src/gen $PROTO

In the generated my-service.pb.go there is now a function called file_v1_my_service_proto_init(), which contains what I assume is meant to be a call to the corresponding init function of other.pb.go. The problem is that this function has the wrong name.

If I look in the generated file for other.proto, its init function is called file_v1_other_proto_init. However, the function we're trying to call from my_proto.pb.go is called file_services_my_org_v1_other_proto_init. It thus seems to assume that the init function name is derived from the file path rather than anything else.

Expected behavior

I would expect consistent names to be used across the board.

Actual Behavior

Somewhere there is a disconnect between what things are actually called and what they are "expected" to be called.

Your Environment

grpc-gateway v2.0.0-beta.4
protoc v 3.12.2

As I said, no idea where the root of this issue is but if possible I would like some input on what's going on here.

Thanks!

@johanbrandhorst
Copy link
Collaborator

Hi!

Sorry you're having some problems. I appreciate you taking the time to open an issue, but this is almost certainly down to some sort of generation environment misconfiguration. For starters, the init functions you're talking about are generated by protoc-gen-go and protoc-gen-go-grpc, which are not maintained in this repo (see https://github.com/protocolbuffers/protobuf-go/ and https://github.com/grpc/grpc-go respectively). I doubt there's anything we can do to fix it, but regardless I'd be happy to help you debug this in a more synchronous environment. Why don't you join the Gophers slack, we have a channel for #protobuf (and another for #grpc and #grpc-gateway) where we could work this out.

I'm going to close this as I believe it is unrelated to our repo. Hope to see you on Slack!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants