-
Notifications
You must be signed in to change notification settings - Fork 513
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
Version 1.8.9 proto: invalid syntax #423
Comments
@EwanValentine, can you provide details about the source file you are trying to use? A small repro case for example? |
same error since 1.8.8
downgrading to 1.8.7 fixes |
@donkeywon, @EwanValentine, I am not able to reproduce this issue. Can you provide information about your source files? A small repro case maybe? |
I'm seeing what looks like the same bug as well. v1.8.8: v1.8.7: After fixing the unresolvable reference grpcurl could correctly describe and call the service, on v1.8.7 and v1.8.8 (and the latest version). |
@printfn, some details on the files you are using, like a repro case, would be incredibly helpful for us to reproduce and fix. Could you give examples on why the reference was unresolvable in your sources? What did you have to change to get them working? |
@jhump apologies, I'll try and come up with a repro case, will take some time/unpicking though |
@jhump I've created a minimal reproduction here: https://github.com/printfn/grpcurl-repro |
@jhump here is the demo, it can reproduce the error https://github.com/donkeywon/proto_demo I found that the error was caused by adding validate |
@donkeywon, it turns out that this is a problem in your proto code, and it just happened to be overlooked by earlier versions of The problem is that the validation proto's proper import path is I'm almost certain that the problems that @EwanValentine and @printfn are seeing has the same root cause: a proto is being imported using the wrong path, so the descriptors can't be linked. The file that is being imported incorrectly is certain to be a file that defines custom options. If it defined actual types needed by your sources (like messages and enums that you use as field types), then even my protoreflect implementation would refuse to process the descriptors. Read this article for more context on getting import paths right and best practices. In any event, @donkeywon, you can fix the code in your demo repo with the following diff: diff --git a/gen_proto.sh b/gen_proto.sh
index 3d9f4e5..827dab7 100755
--- a/gen_proto.sh
+++ b/gen_proto.sh
@@ -1 +1 @@
-protoc -I=. --go-grpc_out=pb --go_out=pb --validate_out="lang=go:pb" proto/*.proto
+protoc -I=. -I=./proto --go-grpc_out=pb --go_out=pb --validate_out="lang=go:pb" proto/*.proto
diff --git a/pb/service.pb.go b/pb/service.pb.go
index d5d6a05..a95a268 100644
--- a/pb/service.pb.go
+++ b/pb/service.pb.go
@@ -119,18 +119,17 @@ var File_proto_service_proto protoreflect.FileDescriptor
var file_proto_service_proto_rawDesc = []byte{
0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x70, 0x72,
- 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c,
- 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x07, 0x43,
- 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x19, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x6d, 0x73,
- 0x67, 0x22, 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a,
- 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0x33, 0x0a,
- 0x06, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12,
- 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
- 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70,
- 0x22, 0x00, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x33,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61,
+ 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x07, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71,
+ 0x12, 0x19, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa,
+ 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x1a, 0x0a, 0x08, 0x43,
+ 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0x33, 0x0a, 0x06, 0x43, 0x65, 0x6e, 0x74, 0x65,
+ 0x72, 0x12, 0x29, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x06, 0x5a, 0x04,
+ 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/proto/service.proto b/proto/service.proto
index c8446ee..ac71f92 100644
--- a/proto/service.proto
+++ b/proto/service.proto
@@ -2,7 +2,7 @@ syntax = "proto3";
package proto;
option go_package = ".;pb";
-import "proto/validate/validate.proto";
+import "validate/validate.proto";
service Center {
rpc Call (CallReq) returns (CallResp) {} |
@jhump thanks for the reply, I will fix it |
@jhump Thanks for the information, and yeah it does look like we’re seeing the same issue. Would it maybe be possible to improve the error message in grpcurl, to better describe the issue? The error message I get on v1.8.7 ( |
@printfn, well, the issue is the way the gRPC Go runtime returns descriptors in this case, from its reflection implementation. Instead of just returning a "not found" error for the missing file, it returns a placeholder descriptor that is invalid. While we could try to special-case this in grpcurl -- like have it look for this particular syntax string and report a different error when it's found -- it would be better IMO to fix the reflection endpoint so that it doesn't return junk descriptors in the first place. With that fix, the error that grpcurl would report would be about the file not being found (in @donkeywon's example, it would complain about |
I've filed grpc/grpc-go#6770 and golang/protobuf#1575 and also opened pull requests to try to fix these issues. |
Just letting you know, version 1.8.9 gives us this error:
Downgrading to 1.8.5 fixes the error. I'm not sure what's causing the error itself, but just a heads up
The text was updated successfully, but these errors were encountered: