Skip to content

Replaced sys.exit() with ClickException in test_connection decorator.…#3705

Open
pui1ya wants to merge 1 commit intoaugurlabs:mainfrom
pui1ya:fix-replace-sysexit-1
Open

Replaced sys.exit() with ClickException in test_connection decorator.…#3705
pui1ya wants to merge 1 commit intoaugurlabs:mainfrom
pui1ya:fix-replace-sysexit-1

Conversation

@pui1ya
Copy link
Copy Markdown

@pui1ya pui1ya commented Feb 17, 2026

Summary

This PR replaces one occurrence of sys.exit() with click.ClickException
in the network connectivity check.

Motivation

As discussed in #3676, sys.exit() bypasses Python's exception handling
and makes testing and error propagation harder. This change establishes a
pattern for handling CLI failures using Click's exception system.

Changes

  • Replaced sys.exit() with click.ClickException
  • No behavioral change intended (CLI still exits with an error message)

Testing

  • Ran tests locally using python -m pytest
  • All existing tests pass

Note: This is intended as the first incremental change before updating the
remaining occurrences.

… Established initial exception handling pattern for CLI failures as discussed in augurlabs#3676.
@MoralCode
Copy link
Copy Markdown
Collaborator

This looks like a small, focused first PR, nice!

Could you test to make sure this works by maybe running the augur CLI uv run augur --help both with and without network connectivity to try and cause this exception to happen? I'd love to see a screenshot or something of what the new output looks like

@MoralCode MoralCode added the testing Related to Augur's testing suite label Feb 17, 2026
@pui1ya
Copy link
Copy Markdown
Author

pui1ya commented Feb 18, 2026

This looks like a small, focused first PR, nice!

Could you test to make sure this works by maybe running the augur CLI 'uv run augur --help' both with and without network connectivity to try and cause this exception to happen? I'd love to see a screenshot or something of what the new output looks like

I tested the decorator by invoking a minimal Click command using 'test_connection'.

With network connectivity, command executes normally.
Without connectivity, ClickException is raised and formatted as an error.

The traceback shown is from existing logging in the decorator (print(traceback.format_exc())), and the final CLI output is handled by Click.

Screenshot attached for when there was no internet connection.
Screenshot 2026-02-18 at 8 34 19 PM

Note: I wasn't able to directly run 'uv run augur --help' locally because the CLI requires database configuration before reaching the decorator, so I tested the decorator in isolation to verify the output behavior.

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

Labels

testing Related to Augur's testing suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants