Deal with TextConsumer errors in CLI
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.
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.
These errors shouldn't be coming from the default backend are they?
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.
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