Non-JSON error responses (e.g. proxy 404 page) surface as "failed to unmarshal response: invalid character"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
问题出在 internal/api/client.go,在检查 resp.StatusCode 之前,响应体就被传给了 json.Unmarshal(大约在第 154 行)。阅读这条响应处理路径,然后用一个返回纯文本 404 的测试服务器复现它。完成的标准是:非 JSON 的错误响应会报告 HTTP 状态码和响应体开头,而不是 JSON 语法错误。在开 PR 之前先与维护者确认,因为该 issue 询问是否会接受这样一个 PR。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Go
- 星标
- 70
- 派生
- 26
- 平均合并
- 4 小时 19 分钟
- 30 天内合并 PR
- 11
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fosrl/cli 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 56/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 53/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 38/100
维护者通常 1 天内回复
-
needs investigating
fosrl/cli#74 · 4 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 62/100
slavakurilyak/awesome-ai-agents#1005 ·
-
agent-research-finding chore
难度 2/5 1-3 小时 新手友好度 78/100
jordansmall/spindrift#7370 ·
维护者通常 1 天内回复
-
☢️ Bug v3
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
The repo's gates check is clean and runs need no swaps可能已有人在做 @turbot-agent-fleet 今天认领。 未关闭agent:ready
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
elecnix/terraform-permcheck#229 ·
维护者通常 1 天内回复