Comments (7)
The thing is - we would still need to have error string parsing inside bblfshd, in order to get this condition as, as one can see in the second link, when this happens the only thing we get from Docker API underneath is
errcode.ErrorCodeUnauthorized
+ an error message string.
Unfortunately, that is sometimes the only available solution. We can write a function to do the translation to canonical codes in one place for this particular API, so that at least we have a seam for fixing regressions from upstream. The important thing from the client's perspective is that they should get reasonably standard error codes for things, and a message they could debug from. 🙂
Obviously parsing stderr is never ideal, but for messages that are generated programmatically it's usually at least possible to bound the set of possible responses. And of course we can always fall back to codes.Unknown
as we do now, for cases we can't detect—that at least preserves the API on our side.
from go-client.
Separately: An error like ErrCodeUnauthorized
probably translates to PermissionDenied
in the gRPC canonical codes. https://godoc.org/google.golang.org/grpc/codes has fairly detailed comments about the intended semantics of each code. The reason I mention this is that it can affect gRPC retry semantics.
from go-client.
It seems like a generally useful thing to have. I'm a little surprised we aren't propagating some kind of standard machine-readable codes here (whether the set from gRPC or otherwise).
from go-client.
This is currently an example of missing driver, and the gRPC error code is Unknown.
✘ se7entyse7en in ~/Projects/.go-workspace/src/github.com/src-d/engine (master) $ go run ./cmd/srcd/main.go parse uast .travis.yml [01/04/19 | 18:38:01.045]
Error: could not stream: rpc error: code = Unknown desc = could not parse: rpc error: code = Unknown desc = unexpected error: runtime failure: missing driver for language "yaml"```
from go-client.
@se7entyse7en true, here is the relevant place where this gets exposed protocol/service.go#L127 and here is how the client works this around bblfshctl/cmd/driver_install.go#L343
@creachadair do you have any insights on what's the best way to propagate these though gRPC? gRPC metadata or something else?
from go-client.
@se7entyse7en true, here is the relevant place where this gets exposed protocol/service.go#L127 and here is how the client works this around bblfshctl/cmd/driver_install.go#L343
@creachadair do you have any insights on what's the best way to propagate these though gRPC? gRPC metadata or something else?
For errors, I would recommend we try to use https://godoc.org/google.golang.org/grpc/status to construct error responses, and set appropriate codes. The *Status
type has a code that we can use (probably codes.NotFound
in this case), and if necessary we can attach extra details that will be propagated in the response.
On the client side, the client can use status.FromError
to retrieve the *Status
value, and inspect the code, message, and/or details.
The exact API varies by language—what I described above uses the Go libraries—but the status mechanism is common to gRPC.
from go-client.
@se7entyse7en true, here is the relevant place where this gets exposed protocol/service.go#L127 and here is how the client works this around bblfshctl/cmd/driver_install.go#L343
@creachadair do you have any insights on what's the best way to propagate these though gRPC? gRPC metadata or something else?For errors, I would recommend we try to use https://godoc.org/google.golang.org/grpc/status to construct error responses, and set appropriate codes. The
*Status
type has a code that we can use (probablycodes.NotFound
in this case), and if necessary we can attach extra details that will be propagated in the response.
Cool it's exactly what we are already using so far on the lower daemon
level inside the bblfshd, but without propagating this to the clients.
The thing is - we would still need to have error string parsing inside bblfshd, in order to get this condition as, as one can see in the second link, when this happens the only thing we get from Docker API underneath is errcode.ErrorCodeUnauthorized
+ an error message string.
If everyone thinks that it's a good idea to do so - I'll be happy to look a bit deeper and submit a PR exposing it later this Q.
\cc @dennwc
from go-client.
Related Issues (20)
- Question: how to get the node's token and internal type HOT 10
- Parsing of >4mb file fails HOT 3
- Context deadline exceeded parsing csharp HOT 5
- Unsupported language using C# as driver HOT 5
- How to calculate the number of immediate children of the node? HOT 7
- How to build nodes from scratch? HOT 4
- How to map nodes? HOT 2
- How to mutate nodes? HOT 2
- Nested XPath should not require *[1] HOT 3
- Add 'bblfsh-cli' binaries to the release assets HOT 4
- Transport closing when client is idle HOT 7
- Question: How do I read data from nodes? HOT 1
- Running bblfsh-cli without params return an "index out of range" error
- errors returned are gRPC errors HOT 4
- Fix an example HOT 2
- Add info about `bblfsh-cli` into the README.md
- `bblfsh-cli --help` gives help message two times
- v2 build fails HOT 3
- Question: how to serialize nodes.Node to protobuf? HOT 4
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-client.