Comments (9)
Is there any workaround? I can't use grpc_cli
tool to test my service because i'm getting similar errors to what @nzoschke is getting.
I0719 17:32:45.627790000 140735610065792 proto_reflection_descriptor_database.cc:84] NOT_FOUND from server for FindFileByName(github.com/mwitkow/go-proto-validators/validator.proto)
[libprotobuf ERROR google/protobuf/descriptor.cc:3632] Invalid proto descriptor for file "accounts.proto":
[libprotobuf ERROR google/protobuf/descriptor.cc:3635] accounts.proto: Import "github.com/mwitkow/go-proto-validators/validator.proto" was not found or had errors.
from go-proto-validators.
Ok, I get the point. But a couple of things:
- just wondering why you need reflection for this?
- how would you recommend we fix it?
- and is this a breaking change
from go-proto-validators.
Happy to see you back on GitHub :).
The registered type name in this case means that any gRPC server that uses the validator in any of its proto files, or imports a proto file that uses a validator cannot use reflection at all. So it's not so much about being able to reflect on the validation itself but the incompatibility it creates.
The fix would be to change the go_package
option to specify a package relative to the gopath src directory, and regenerate the file, (e.g. github.com/mwitkow/go-proto-validators;validator
).
Off the top of my head I don't think it should be a breaking change but I don't have my laptop to hand to test right now.
from go-proto-validators.
Oh I wasn't aware that the grpc reflection was broken. We don't use it ourselves.
Can you iron out a PR with a fix as you seem to have the environment to test it?
from go-proto-validators.
I'll see what I can do.
from go-proto-validators.
Having done some cursory investigating, I think this would be blocked on #26 anyway, as the generated file registers with gogo/protobuf
explicitly, and grpc-go reflection is tightly coupled with golang/protobuf
. For anyone else wanting to test this, I created a repo with a simple reflection environment.
from go-proto-validators.
I am having trouble with this too.
I am adding the import and validator options in my .proto:
syntax = "proto3";
package sources.v0;
import "google/protobuf/timestamp.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
option go_package = "github.com/myorg/proto-api/server/sources/v0;sources";
service Sources {
rpc Get (SourcesGetRequest) returns (SourcesGetResponse) {}
rpc List (SourcesListRequest) returns (SourcesListResponse) {}
}
message SourcesGetRequest {
string name = 1 [(validator.field) = {regex: "^[a-z]{2,5}$"}];
}
Things build just fine with:
//go:generate protoc --go_out=plugins=grpc:${GOPATH}/src --govalidators_out=${GOPATH}/src -I ../../../proto/sources/v0 --proto_path=${GOPATH}/src sources.proto
I can see my service:
$ grpcurl -plaintext localhost:3000 list
grpc.reflection.v1alpha.ServerReflection
helloworld.Greeter
sources.v0.Sources
But I can't use it due to errors:
$ grpcurl -plaintext localhost:3000 describe sources.v0.Sources
Failed to resolve symbol "sources.v0.Sources": Symbol not found: sources.v0.Sources
caused by: File not found: github.com/mwitkow/go-proto-validators/validator.proto
$ grpcurl -plaintext -d '{"name": "test"}' localhost:3000 sources.v0.Sources.Get
Error invoking method "sources.v0.Sources.Get": target server does not expose service "sources.v0.Sources"
If I remove the import "github.com/mwitkow/go-proto-validators/validator.proto";
things are fine.
from go-proto-validators.
This is because go-proto-validators
registers with the gogoprotobuf registry. See
go-proto-validators/validator.pb.go
Line 16 in 0950a79
from go-proto-validators.
Unfortunately, gogoproto simply does not work with gRPC reflection. See https://jbrandhorst.com/post/gogoproto/ for more information.
from go-proto-validators.
Related Issues (20)
- Does this work with APIv2? HOT 1
- go get report error, thanks for help
- could error message FieldName be json tag?
- import order changed
- Mask sensitive fields
- Support for multibyte strings
- is_in_enum combined with int_gt doesn't work
- Support for optional field HOT 4
- How to build this for NodeJS?
- nice, continue to update and iterate plase
- panic: interface conversion: interface {} is []uint8, not *validator.FieldValidator
- Error when building with bazel
- How to build this for python?
- Publish to buf schema register HOT 2
- is this repo still maintained? HOT 1
- How to specify path for generated validator.go ? HOT 2
- protoc command error
- Bad Code Generated HOT 1
- compiles files that dont have any validator notation
- generate code can not support option 'module' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-proto-validators.