Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

CLI: connectivity check prints diagnostics to stdout, breaking piped output

Đang mở Phù hợp với người mới
#548 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu với check_connectivity() và bộ gọi @test_connection của nó trong collectoss/application/cli/__init__.py; chạy lệnh tái hiện bằng Python của issue để quan sát chẩn đoán trên stdout và traceback. Xác minh rằng các kiểm tra thành công giữ cho stdout sạch, các kiểm tra thất bại báo cáo chẩn đoán qua stderr hoặc logging và các thông báo lỗi sử dụng exception đã bắt; thêm hoặc cập nhật các kiểm thử CLI tập trung nếu cấu trúc kiểm thử hiện có của dự án cung cấp điều đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description:
check_connectivity() in collectoss/application/cli/__init__.py (used by @test_connection) reports failures with print(), so they go to stdout. It prints for every failed URL even when a later URL succeeds and the command runs normally, and for network/protocol errors it also prints a full traceback. This puts stray lines at the top of a working command's stdout and breaks piping, e.g. JSON output. The "no way to get connection to the database" error also goes to stdout.

Also, the network/protocol error messages print the exception class ({httpx.NetworkError}) instead of the caught exception ({e}).

Question for maintainers: is CLI output a stable API surface, and should diagnostics go to stderr? Found while working on #547 .

How to reproduce:
Run, with the first URL unreachable and the second reachable: uv run python -c “from collectoss.application.cli import check_connectivity as c; c([‘http://10.255.255.1','http://github.com’])” 2>/dev/null

stdout gets Connectivity test Request 0 Network Error: <class 'httpx.NetworkError'> plus a traceback, even though the function returns True. In normal use this happens when any of chaoss.community, github.com or gitlab.com is slow or unreachable.

Expected behavior:
Diagnostics go to stderr (or logging), and only when the check actually fails, so collectoss <command> > out.json gives valid output. Error messages include the caught exception.

Screenshots
N/A

Log files
Full output (~55 lines):

Software versions:

  • CollectOSS: 4027f1212
  • OS: macOS 12.6.7 (21G651)
  • Browser: N/A
Ngôn ngữ chính
Python
Star
17
Fork
27
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của chaoss/CollectOSS

Tất cả issue của chaoss/CollectOSS

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.