Non-JSON error responses (e.g. proxy 404 page) surface as "failed to unmarshal response: invalid character"
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Vấn đề nằm ở internal/api/client.go, nơi body của response được đưa vào json.Unmarshal (khoảng dòng 154) trước khi resp.StatusCode được kiểm tra. Hãy đọc luồng xử lý response đó, rồi tái hiện nó bằng một test server trả về 404 dạng plain-text. Hoàn thành nghĩa là một phản hồi lỗi không phải JSON báo cáo HTTP status và phần đầu của body thay vì lỗi cú pháp JSON. Xác nhận với các maintainer trước khi mở PR, vì issue hỏi liệu một PR như vậy có được chấp nhận không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 70
- Fork
- 26
- Merge trung bình
- 4 giờ 19 phút
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fosrl/cli
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Automatic Site UpdatesĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 53/100
fosrl/cli#179 · 13 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs investigating
fosrl/cli#74 · 4 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Project submission: xmcp DocsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
slavakurilyak/awesome-ai-agents#1005 ·
-
agent-research-finding chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jordansmall/spindrift#7370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
☢️ Bug v3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
The repo's gates check is clean and runs need no swapsCó thể đã có người làm @turbot-agent-fleet đã nhận hôm nay. Đang mởagent:ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
turbot/tailpipe#677 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
elecnix/terraform-permcheck#229 ·
Maintainer thường phản hồi trong vòng 1 ngày