Skip to content

Replace bare exception handlers in whaletag SSH functions#43

Open
InterstellarIntruder wants to merge 1 commit into
Project-CETI:mainfrom
InterstellarIntruder:fix/39-bare-exception-handlers
Open

Replace bare exception handlers in whaletag SSH functions#43
InterstellarIntruder wants to merge 1 commit into
Project-CETI:mainfrom
InterstellarIntruder:fix/39-bare-exception-handlers

Conversation

@InterstellarIntruder
Copy link
Copy Markdown

@InterstellarIntruder InterstellarIntruder commented Apr 17, 2026

Fixes #39

get_hostname_by_addr() and can_connect() were catching all exceptions silently -- wrong password, network timeout, SSH server down all returned False with no error message. This made it impossible to debug connection failures in the field.

Changes:

  • Catch paramiko.AuthenticationException, paramiko.SSHException, and OSError instead of bare except: / except BaseException:
  • Log each failure with the target address and error message
  • KeyboardInterrupt and SystemExit are no longer swallowed

Tests:
9 new unit tests in tests/test_whaletag.py covering success paths, each failure type, and KeyboardInterrupt propagation.

@InterstellarIntruder InterstellarIntruder force-pushed the fix/39-bare-exception-handlers branch from c6c482f to f6c715b Compare April 17, 2026 20:37
get_hostname_by_addr() and can_connect() were catching all exceptions
silently, making it impossible to debug connection failures in the
field. Now catches paramiko.SSHException, AuthenticationException,
and OSError specifically, and logs the error with the target address.

Adds 9 unit tests covering success, auth failure, SSH errors,
network errors, and KeyboardInterrupt propagation.

Fixes Project-CETI#39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bare Exception Handler (Silent Failures)

1 participant