You signed in with ano
8000
ther tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-JSON error responses (e.g. proxy 404 page) surface as "failed to unmarshal response: invalid character" #194
We use pangolin ssh (CLI 0.23.0, macOS arm64) against a self-hosted Pangolin that sits behind a reverse proxy. For a few hours one of the proxy's upstreams was misrouted and answered every second request with a plain-text 404 page not found. The CLI reported this as:
SSH error: failed to unmarshal response: invalid character 'p' after top-level value
It took us a while to work out that this was an HTTP 404 from the proxy and not a Pangolin or SSH problem, because the status code and body never show up in the error.
What happens
In internal/api/client.go the response body goes straight into json.Unmarshal (around line 154 on main today), before resp.StatusCode is looked at. So any non-JSON error body, like a proxy 404/502 page or a captive portal, comes out as a JSON syntax error. I'd have expected something like HTTP 404: 404 page not found.
What we have ruled out
The fault was on our side (a stale upstream connection in our proxy), and we've fixed it. The Pangolin server itself was healthy. Requests that reached it got normal JSON replies. This issue is only about the error message the CLI shows when a reply isn't JSON.
Reproduction
Point the CLI at any endpoint that returns a non-JSON body, e.g. a reverse proxy route with no backend that answers 404 page not found, then run any command that calls the API (pangolin ssh sign <resource>).
A guess at a fix: when unmarshalling fails, include resp.StatusCode and the first ~100 bytes of the body in the error, or check for a non-2xx status first. Would you take a PR for that? I had an agent go through the client code with me, so please correct me if I've misread the flow.
I can take this one. Plan: check the status code before decoding, and when the body isn't JSON return an error with the HTTP status plus a short snippet of the body (e.g. HTTP 404: 404 page not found), with tests for the 404/502/HTML cases. Will open a PR shortly unless a maintainer would rather do it differently.
Activity
harshbhx commentedon Nov 21, 2026
I can take this one. Plan: check the status code before decoding, and when the body isn't JSON return an error with the HTTP status plus a short snippet of the body (e.g.
HTTP 404: 404 page not found), with tests for the 404/502/HTML cases. Will open a PR shortly unless a maintainer would rather do it differently.harshbhx commentedon Nov 21, 2026
Releasing this one, I won't be able to follow it through after all. It's open for anyone else to pick up.