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: failed to import google/api/annotations.proto #433

Closed
prashcr opened this Issue May 23, 2016 · 9 comments

Comments

Projects
None yet
4 participants
@prashcr

prashcr commented May 23, 2016

It seems to be trying to import a local file called google/api/annotations.proto rather than enable options

Related issue: grpc-ecosystem/grpc-gateway#165

@prashcr prashcr closed this May 23, 2016

@c3s4r

This comment has been minimized.

c3s4r commented Dec 22, 2016

Did you find a solution for this? I'm having the same issue when trying to create an GRPC server in node.

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 22, 2016

It might be required to add google/api/annotations.proto and its dependencies to your application, if not bundled with grpc already. protobuf.js doesn't bundle it.

@prashcr

This comment has been minimized.

prashcr commented Dec 27, 2016

Yep, that's what I did.

@konsumer

This comment has been minimized.

konsumer commented Feb 3, 2017

If it's commented out, it works without error, but also it seems that there is a mechanism for handling missing but optional files (#368).

So, basically, we can do this before a grpc parse:

require('protobufjs').common('google/api/annotations.proto', {})

Since the annotation lib isn't needed by grpc (it parses the options directly.)

@konsumer

This comment has been minimized.

konsumer commented Feb 3, 2017

But it looks like the version required by gRPC doesn't have common()...

protobuf.common is not a function
@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Feb 3, 2017

gRPC is still in the process of upgrading to protobuf.js v6. If no definitions from annotations.proto are used, actually, you could also just create an empty file at current working directory + /google/api/annotations.proto.

@konsumer

This comment has been minimized.

konsumer commented Feb 3, 2017

would that work for nested structures, or just top-level proto files?

I ended up doing this in with grpc:

const getProto = (protoFile) => {
  protobuf.common(`${path.dirname(protoFile)}/google/api/annotations.proto`, {})
  return grpc.load(protoFile)
}

Which works ok for single-level RPC service definitions, but I had to add a dependency for a newer version of protobuf to my project (to override grpc's) for it to work.

@konsumer

This comment has been minimized.

konsumer commented Feb 3, 2017

Oh wait, that didn't actually work (I had it commented out, still.) Dummy file works for single-level rpc definitions and doesn't seem to break protoc stuff.

@konsumer

This comment has been minimized.

konsumer commented Feb 3, 2017

If there was a concept of "include path" like protoc, I could be using my existing protoc include dir, which has this and also the common types. Maybe this is more of an issue for grpc.

dcodeIO added a commit that referenced this issue Feb 4, 2017

CLI: Added an experimental --sparse option to limit pbjs output to ac…
…tually referenced types within main files; Other: Added a few more common google types from google/api, see #433
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment