Skip to content

fix(cli): report a clean error when wingfoot sign can't reach the URL - #4

Merged
AmirF194 merged 1 commit into
AmirF194:mainfrom
ebarkhordar:fix/sign-connection-error
Jul 19, 2026
Merged

fix(cli): report a clean error when wingfoot sign can't reach the URL#4
AmirF194 merged 1 commit into
AmirF194:mainfrom
ebarkhordar:fix/sign-connection-error

Conversation

@ebarkhordar

Copy link
Copy Markdown
Contributor

Problem

http.request deliberately returns a Response for 4xx/5xx (no exception), but a connection failure — DNS error, connection refused, timeout — has no HTTP status, so it propagates as urllib.error.URLError. cmd_sign calls http.request without catching it, so a wingfoot sign against an unreachable URL dumps a raw Python traceback:

$ wingfoot sign http://127.0.0.1:1/
Traceback (most recent call last):
  ...
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

doctor already guards against this (via _safe_request); sign didn't.

Fix

Catch urllib.error.URLError in cmd_sign and print a concise message to stderr, returning exit code 1:

$ wingfoot sign http://127.0.0.1:1/
Could not reach http://127.0.0.1:1/: [Errno 61] Connection refused

Tests

Added to tests/test_cli.py:

  • test_sign_reports_connection_error_cleanly — a URLError from the request becomes a clean stderr message + exit 1 (no traceback).
  • test_sign_print_only_needs_no_network--print-only never touches the network.

Full suite: 47 passed (45 + 2 new).

http.request returns a Response for 4xx/5xx but lets connection failures
(DNS, refused, timeout) propagate as urllib.error.URLError, since they
have no HTTP status. cmd_sign didn't catch it, so `wingfoot sign` against
an unreachable URL dumped a Python traceback.

Catch URLError in cmd_sign and print a concise message to stderr with
exit code 1, matching how doctor already handles unreachable targets.
Add tests for the connection-error path and that --print-only stays offline.
@AmirF194
AmirF194 merged commit c74df5d into AmirF194:main Jul 19, 2026
5 checks passed
@AmirF194 AmirF194 mentioned this pull request Jul 19, 2026
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.

2 participants