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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate implicit dependencies #2743

Open
gigi opened this issue Jan 29, 2024 · 4 comments
Open

Generate implicit dependencies #2743

gigi opened this issue Jan 29, 2024 · 4 comments

Comments

@gigi
Copy link

gigi commented Jan 29, 2024

Hello!

We are trying to implement Richer Error Model for gRPC.

We want to include such dependencies like google.rpc.Status and all messages from error_details.proto to our distributed package during the build stage.

I see that https://buf.build/googleapis/googleapis/docs/main:google.rpc has all necessary dependencies.

How can we include all needed dependencies to our descriptors and generated models with buf build and buf generate?

Thank you!

@smallsamantha
Copy link
Member

Hi @gigi - check out the Buf Schema Registry tutorial! This will walk you through adding a dependency on googleapis and using buf build and buf generate with this dependency.

@gigi
Copy link
Author

gigi commented Jan 29, 2024

Hey @smallsamantha,
Thanks for quick response!

We've already added the googleapis dependencies and they work for dependencies that are explicitly imported into the .proto files.

Is there a way to include dependencies mentioned above that are part of the infrastructure layer and not part of the business protocol?

@smallsamantha
Copy link
Member

The answer for how to do that depends on the language you're using in your implementation. For example, if you're using go, we recommend using google.golang.org/genproto/googleapis/rpc/errdetails as described in our Connect error details documentation here. If you're using another language you may need to explicitly generate the types from googleapis similar to how you're generating your own definitions. So you might run buf generate buf.build/googleapis/googleapis in addition to your buf generate myprotos invocation.

Let me know if that gets you going in the right direction!

@gigi
Copy link
Author

gigi commented Jan 30, 2024

We use NestJS. It seems there is no proper error details support under the hood.
We have to pack and pass metadata via trailers by hand.

Such tools like grpcui or Kreya.app don't support error_details out of the box and its convenient to pass just one descriptors file that includes all necessary protos.

buf generate buf.build/googleapis/googleapis

This approach resolves a lot of not used protos. We should remove all except two files)

We ended up with empty file with necessary imports and excluded this file from buf lint command...

syntax = "proto3";

package app.rpc.v1;

import "google/rpc/status.proto";
import "google/rpc/error_details.proto";

option csharp_namespace = "app.Rpc.V1";
option go_package = "app/rpc/v1";
option java_multiple_files = true;
option java_package = "com.app.rpc.v1"; 

It works for now... Maybe we will find better solution soon
Thanks for your answers

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