fix(cli): report a clean error when wingfoot sign can't reach the URL - #4
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
http.requestdeliberately returns aResponsefor 4xx/5xx (no exception), but a connection failure — DNS error, connection refused, timeout — has no HTTP status, so it propagates asurllib.error.URLError.cmd_signcallshttp.requestwithout catching it, so awingfoot signagainst an unreachable URL dumps a raw Python traceback:doctoralready guards against this (via_safe_request);signdidn't.Fix
Catch
urllib.error.URLErrorincmd_signand print a concise message to stderr, returning exit code 1:Tests
Added to tests/test_cli.py:
test_sign_reports_connection_error_cleanly— aURLErrorfrom the request becomes a clean stderr message + exit 1 (no traceback).test_sign_print_only_needs_no_network—--print-onlynever touches the network.Full suite: 47 passed (45 + 2 new).