Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Protos with imported dependencies cannot be loaded #102

Closed
taywrobel opened this issue Jul 25, 2019 · 6 comments
Closed

Protos with imported dependencies cannot be loaded #102

taywrobel opened this issue Jul 25, 2019 · 6 comments

Comments

@taywrobel
Copy link

On a larger codebase of ours, we have protos split between multiple files. In particular, the data model protos, which are shared amongst multiple parts of the system, are in a separate file from the service protos, and are imported. Simplified example below:

protos/exampleModel.proto:

syntax = "proto3";
package protos;

message Value {
  string name = 1;
  string id = 2;
}

protos/exampleService.proto:

syntax = "proto3";
package protos;

import "protos/exampleModel.proto";

service ExampleService {
  rpc RunSearch (ExampleSearch) returns (SearchResponse) {}
}

message ExampleSearch {}

message SearchResponse {
  repeated Value items = 1;
}

These protos, placed in the same directly, compile fine with protoc, and the import is resolved. However I'm unable to load service.proto into bloom. Attempting to load the two together or loading the model before the service proto yields the same error: "no such Type or Enum 'Value' in Type .protos.SearchResponse"

@fenos
Copy link
Contributor

fenos commented Jul 26, 2019

@twrobel3 Hi there!

I've tried your example protos my self and i've got the same error.
Although i then noticed that you have something wrong in your protos/exampleService.proto.

If both of the protos lives within the same folder then your import should be only import "exampleModel.proto"; without the protos prefix`. If you try to load it like this it works.

The reason why your protoc works is because you probably have set an import path resolution.

So if you don't want to change your import, you need to tell bloomrpc the same thing.

  • Open the import path option on the sidebar
  • Add the absolute path the to folder one step back to the protos folder.
  • Click add +
  • Try importing again

@fenos
Copy link
Contributor

fenos commented Jul 29, 2019

Let me know if that solve your issue, for now closing

@fenos fenos closed this as completed Jul 29, 2019
@tooolbox
Copy link

@fenos this solved my issue--thank you!

(Might want to put this in an FAQ or something.)

@sheralam
Copy link

** Add the absolute path the to folder one step back to the protos folder. thanks, @fenos. works as charm

@codewicked
Copy link

This works. Thank you @fenos

@shrader
Copy link

shrader commented Jun 29, 2022

Thanks @fenos. Leaving the import the same and adding the parent folder of proto to Bloom's Import Paths worked for me also.

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

No branches or pull requests

6 participants