Commit 371fa4b
v0.0.8 polish: CLI catches all socket errors, not just URLError
CAUGHT BY CLEAN-VENV INSTALL TEST (Roli requested isolated install
verification before sharing with technical friends):
`fidelis health` against the live local fidelis-server crashed with a
Python traceback (ConnectionResetError: [Errno 54] Connection reset by
peer) instead of a clean error message.
Root cause: cli.py:_get and _post caught only urllib.error.URLError.
Socket-level failures (ConnectionResetError, BrokenPipeError, TimeoutError)
are OSError subclasses, NOT URLError. They escaped the handler and showed
a 30-line traceback to the user.
Fix:
- Added _server_error() helper that prints a multi-line clean error
(server URL, error reason, two next-step hints) and exits 1.
- Both _get and _post now catch (URLError, OSError, JSONDecodeError) —
the full family of failure modes a user might hit:
* ECONNREFUSED → URLError (server not running)
* ECONNRESET → OSError (server crashed mid-response — pre-existing
intermittent fidelis-server behavior)
* Timeout → OSError (server slow / hung)
* HTTP 500 with broken-pipe → OSError
* Server returns non-JSON → JSONDecodeError
UX before:
Traceback (most recent call last):
File '...', line 6, in <module>
sys.exit(main())
[30 lines of stack trace]
ConnectionResetError: [Errno 54] Connection reset by peer
UX after:
Error: fidelis-server unreachable or unhealthy at http://127.0.0.1:19420
reason: [Errno 54] Connection reset by peer
• If you haven't installed the service: `fidelis init`
• If the service is installed: `tail ~/.fidelis/server.log`
Verified:
- exit code 1 on real failure
- exit code 0 on server-up success
- no false positives (server-up health check still returns clean output)
Tests: 375 scaffold tests still passing.
This was the kind of UX bug a friend share would have hit on first run.
Caught + fixed before any external share.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3dc1748 commit 371fa4b
1 file changed
Lines changed: 15 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| |||
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 56 | + | |
| 57 | + | |
49 | 58 | | |
50 | 59 | | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| |||
0 commit comments