GithubHelp home page GithubHelp logo

Comments (7)

creachadair avatar creachadair commented on August 23, 2024 1

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.

creachadair avatar creachadair commented on August 23, 2024 1

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.

creachadair avatar creachadair commented on August 23, 2024

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.

se7entyse7en avatar se7entyse7en commented on August 23, 2024

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.

bzz avatar bzz commented on August 23, 2024

@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.

creachadair avatar creachadair commented on August 23, 2024

@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.

bzz avatar bzz commented on August 23, 2024

@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.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.