Closed benarent closed 2 years ago
Adding error-msg
to this issue. This is due to not being able to connect to the public endpoint.
@benarent I renamed the issue to something more specific so that I can bring it up on our Slack channel.
This happens if the --proxy
flag points to a server that's not a Teleport Proxy. I've run into this a number of times. It's super easy to run into this, be it a configuration error on some load balancer or simply making a typo, say typing 'myteleportcluster.cominstead of
proxy.myteleportcluster.com`. The error message doesn't help you spot the problem.
$ tsh login --proxy=example.com:443 -d
DEBU Attempting GET example.com:443/webapi/ping webclient/webclient.go:115
ERROR REPORT:
Original Error: *json.SyntaxError invalid character '<' looking for beginning of value
Stack Trace:
/Users/rav/Projects/teleport/api/client/webclient/webclient.go:208 github.com/gravitational/teleport/api/client/webclient.Ping
/Users/rav/Projects/teleport/lib/client/api.go:3528 github.com/gravitational/teleport/lib/client.(*TeleportClient).Ping
/Users/rav/Projects/teleport/lib/client/api.go:3145 github.com/gravitational/teleport/lib/client.(*TeleportClient).PingAndShowMOTD
/Users/rav/Projects/teleport/lib/client/api.go:3189 github.com/gravitational/teleport/lib/client.(*TeleportClient).Login
/Users/rav/Projects/teleport/tool/tsh/tsh.go:1320 main.onLogin
/Users/rav/Projects/teleport/tool/tsh/tsh.go:875 main.Run
/Users/rav/Projects/teleport/tool/tsh/tsh.go:397 main.main
/opt/homebrew/Cellar/go/1.18.1/libexec/src/runtime/proc.go:250 runtime.main
/opt/homebrew/Cellar/go/1.18.1/libexec/src/runtime/asm_arm64.s:1259 runtime.goexit
User Message: invalid character '<' looking for beginning of value
This happens because webclient.Config.Ping
doesn't check if the response was successful (it only checks for the 400 status code) and immediately assumes that the response body is in json format and throws it to the parser.
At minimum I think tsh should do two more things:
Content-Type
header of the response before attempting to pass the body to the JSON parser.If any of those checks fails, tsh could show a message like "The request to example.com:443/webapi/ping was not successful. This might be because the Teleport proxy server is offline or example.com:443 doesn't point to a Teleport proxy server".
We should also make sure the fix for this issue also plays well with a situation where the user doesn't specify a port of the proxy. In that case we have some kind of mechanism to guess the port number and the behavior of tsh is a bit different.
Description
While trying to connect to a new demo cluster locally. I think it's due to the proxy in-front of these demo instances but the error message isnt' clear.
What happened:
What you expected to happen:
Reproduction Steps
As minimally and precisely as possible, describe step-by-step how to reproduce the problem. 1. 2. 3.
Server Details
teleport version
):/etc/os-release
):Client Details
tsh version
):Debug Logs
Please include or attach debug logs, when appropriate. Obfuscate sensitive information!
teleport --debug
)tsh --debug
)