Skip to content

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

Open

Description

@Inengs

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: 4027f12
  • OS: macOS 12.6.7 (21G651)
  • Browser: N/A

Activity

  1. Nimisha987 commented on Nov 24, 2026

    @Nimisha987

    Hi! I'd like to work on this issue.

    I went through the problem with check_connectivity() printing diagnostics and tracebacks to stdout, which can interfere with piped command output.

    I'd like to investigate the existing CLI implementation, fix the output handling, and add regression tests to ensure diagnostics go to stderr while successful command output remains clean.

    Could you please assign this issue to me, or let me know if I can proceed with a PR?

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions