dispatch icon indicating copy to clipboard operation
dispatch copied to clipboard

Deal with TextConsumer errors in CLI

Open kars7e opened this issue 8 years ago • 4 comments

If for some reason API returns text content type (e.g. because of some internal error or due to Ingress error), CLI craps out with an unfriendly error message. CLI should be able to at least print the body of text error or catch it and return more usable message.

kars7e avatar Dec 13 '17 00:12 kars7e

I've found that it should be possible to modify the default-backend provided by the ingress controller to supply json content for errors instead of text/plain. Here is a link to documentation about this https://github.com/kubernetes/ingress-nginx/tree/master/docs/examples/customization/custom-errors . Unfortunately the documentation has some broken links and doesn't actually seem to provide a working example. If we can modify this default backend to always translate the error to a JSON object that includes a 'code' and 'message' then the rest of the app should work as desired.

tenczar avatar Dec 13 '17 22:12 tenczar

These errors shouldn't be coming from the default backend are they?

berndtj avatar Dec 13 '17 23:12 berndtj

So in the case that I was investigating with retrieving runs that was the issue. At the very least any error generated by the default backend can be returned as a JSON with a code and a message which would allow them to be translated to our swagger errors. I believe all of the errors that we define in swagger include at least a code and a message.

tenczar avatar Dec 14 '17 00:12 tenczar

This occurs when a user is not logged in and tries to use the dispatch cli

$ dispatch get images
received unexpected error: &{0 <nil>} (*models.Error) is not supported by the TextConsumer, can be resolved by supporting TextUnmarshaler interface
$ curl -k https://dispatch.kops.bjung.net/v1/image
default backend - 404

berndtj avatar Dec 18 '17 17:12 berndtj