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

Error: No such type 'BMessage' in package '' when compiling .proto files #80

Open
am0314 opened this issue Nov 27, 2024 · 3 comments
Open

Comments

@am0314
Copy link

am0314 commented Nov 27, 2024

Hi,

I encountered an issue while trying to compile .proto files using your library. Here is the detailed setup and problem:

File Descriptions

a.proto:

syntax = "proto3";
package nrpctest;
option go_package = "./ab_pb";
message AMessage {
    int32 AA =1;
}

b.proto:

proto

syntax = "proto3";
package nrpctest;

import "a.proto";

option go_package = "./ab_pb";

service BRPC {
    rpc B(AMessage) returns (AMessage);
    rpc C(BMessage) returns (BMessage);
}
message BMessage {
    int32 BB = 1;
}

Compilation Command

protoc --go_out=. --nrpc_out=. b.proto

Error Message

No such type 'BMessage' in package ''

This error makes it unclear why BMessage isn't recognized as part of the defined package or type system.

Could you please help clarify if this is a bug in the library or if there's a missing configuration on my side?

Thank you for your assistance!

@cdevienne
Copy link
Member

I think protoc-gen-nrpc does not handle a package splitted in several files.
If you put the a.proto file in a different package, or merge both files, it should workaround the issue.

@am0314
Copy link
Author

am0314 commented Nov 27, 2024

Yes, when merging everything into a single file, the compilation works fine. However, doing so would require me to repeatedly define the same entities across multiple files. For example, I use .proto files to define error codes. If each .proto file has to independently define the same error codes and keep them synchronized, it would introduce a significant maintenance burden.

That's why I was hoping to use import statements to reference other .proto files and still successfully compile with nrpc. Additionally, when using grpc_out to generate grpc.go files, the compilation works without any issues.

@cdevienne
Copy link
Member

It definitely is as issue that needs fixing, I was just suggesting a workaround. Meanwhile if you need to keep a separated file for codes, you can put it in a different package.

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