Error using package namespace in proto with . in it
See original GitHub issueI have found an issue where grpc-dynamic-gateway crashes if the package in the proto file contains a . in it (which is helpful for clean code generation in languages like C++)
i.e. this fails:
syntax = "proto3";
package test.stuff;
import "google/api/annotations.proto";
service TestService
{
rpc TestRpc (TestParams) returns (TestData)
{
option (google.api.http) =
{
post: "/v1/assets/op/execute"
body: "*"
};
}
}
message TestParams
{
string testField = 1;
}
message TestData
{
string myData = 1;
}
With this error:
C:\Users\graham\Documents\Repositories\halcyon>grpc-dynamic-gateway -g 0.0.0.0:50060 -I ./Proto/proto AssetService2.proto
C:\Users\graham\AppData\Roaming\npm\node_modules\grpc-dynamic-gateway\index.js:34
clients[pkg][svc] = new protos[si][pkg][svc](grpcLocation, credentials)
^
TypeError: Cannot read property 'TestService' of undefined
at sch.services.forEach.s (C:\Users\graham\AppData\Roaming\npm\node_modules\grpc-dynamic-gateway\index.js:34:48)
at Array.forEach (native)
at protoFiles.map.map.forEach (C:\Users\graham\AppData\Roaming\npm\node_modules\grpc-dynamic-gateway\index.js:32:20)
at Array.forEach (native)
at middleware (C:\Users\graham\AppData\Roaming\npm\node_modules\grpc-dynamic-gateway\index.js:29:6)
at Object.<anonymous> (C:\Users\graham\AppData\Roaming\npm\node_modules\grpc-dynamic-gateway\cli.js:61:26)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
While this:
syntax = "proto3";
package teststuff;
import "google/api/annotations.proto";
service TestService
{
rpc TestRpc (TestParams) returns (TestData)
{
option (google.api.http) =
{
post: "/v1/assets/op/execute"
body: "*"
};
}
}
message TestParams
{
string testField = 1;
}
message TestData
{
string myData = 1;
}
Works fine:
C:\Users\graham\Documents\Repositories\halcyon>grpc-dynamic-gateway -g 0.0.0.0:50060 -I ./Proto/proto AssetService2.proto
POST /v1/assets/op/execute
Listening on http://0.0.0.0:8080, proxying to gRPC on 0.0.0.0:50060
Thank you, Graham
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
problem with namespace · Issue #159 · golang/protobuf - GitHub
Your problem is that you're translating A.proto and B.proto separately. The plugin assumes that everything passed together is in the same ...
Read more >Language Guide (proto3) | Protocol Buffers - Google Developers
This guide describes how to use the protocol buffer language to structure your protocol buffer data, including .proto file syntax and how to...
Read more >How to fix "The type of namespace name "Fault" does not exist ...
Do this: Right click on your .proto file in the Visual Studio solution explorer. Choose "Properties"; Change "Build action" to "Protobuf ...
Read more >protobuf avoid namespace conflict - Google Groups
Hi! I have two packages server and client. All belongs to different repos. In this packages i have internal/errors dir with errors.proto
Read more >Troubleshoot gRPC on .NET Core - Microsoft Learn
Troubleshoot errors when using gRPC on .NET Core. ... gRPC C# assets are not code generated from .proto files.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Changing the
getPkg
function to this should fix it:When this will be published?