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

Buf - Wrong import in grpcgateway #3801

Open
Aldiwildan77 opened this issue Dec 9, 2023 · 2 comments
Open

Buf - Wrong import in grpcgateway #3801

Aldiwildan77 opened this issue Dec 9, 2023 · 2 comments

Comments

@Aldiwildan77
Copy link

Aldiwildan77 commented Dec 9, 2023

馃悰 Bug Report

image
GRPC Gateway generates the wrong grpc import, so when I do go run . the error occurs

# buf.build/gen/go/mocha/remcall/grpc-ecosystem/gateway/v2/donut/v1/matchmaker/donutv1gateway
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:36:108: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:53:114: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:70:116: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:96:122: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:122:107: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:148:113: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:174:106: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:200:112: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:230:96: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:371:96: undefined: donutv1grpc
C:\Users\Administrator\go\pkg\mod\buf.build\gen\go\mocha\remcall\grpc-ecosystem\gateway\v2@v2.18.1-20231209063154-4f8472b3e8fa.1\donut\v1\matchmaker\donutv1gateway\matchmaker.pb.gw.go:371:96: too many errors

To Reproduce

(Write your steps here:)

  1. Create the proto with buf, in this case, look at my repo
  2. Push to the BSR (using CI CD via GitHub action, look at the repo above)
  3. Run a go get to get the BSR generated SDK
  4. Do the grpc gateway implementation (https://github.com/grpc-ecosystem/grpc-gateway?tab=readme-ov-file#5-write-an-entrypoint-for-the-http-reverse-proxy-server)
  5. Run the golang service, check the error and module import

Expected behavior

import "buf.build/gen/go/mocha/remcall/grpc/go/donut/v1/donutv1grpc"

Actual Behavior

image

import "buf.build/gen/go/mocha/remcall/grpc/go/mopay/v1/mopayv1grpc"

Your Environment

OS: Windows 11
Go Version: go1.21.0 windows/amd64
Buf Version (local): 1.27.0
Buf Version (Github Action): latest

@johanbrandhorst
Copy link
Collaborator

Hi, thanks for your issue. I'm not entirely sure what's going on here - you're saying that the import that's generated by the Buf SDK remote generation is wrong? I don't see any generated files in the repo you linked, so I assume there's something that's going wrong with the remote packages. Have you tried asking for help on the Buf slack? There might be an issue with the gateway but I can't really see it from what you've shared.

@seinshah
Copy link

seinshah commented Apr 23, 2024

The same issue happened in my case as well. Having two services structured as

-org
--module
---service1
----v1
-----service.proto
---service2
----v1
-----service.proto

I was using the generated SDK for grpc-gateway (plugin version 2.19.1). Initially, when I created the module only org.module.service1.v1 package was available and later I added org.module.service2.v1 package.

I noticed that in the generated grpc-gateway under buf.build/gen/go/<org>/<module>/grpc-ecosystem/gateway/v2/<org>/<module>/service2/v1/service/service2v1gateway/service.pb.gw.go there is an import for the service1v1 grpc client.

Though, this happens only if I use buf.build generated SDKs. If I use buf generate myself with my own buf.gen.yaml everything is fine.

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

3 participants