Wrap connection and TLS errors from RemoteClient as NetworkError - #324
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
_request wrapped requests.Timeout as NetworkError but re-raised ConnectionError and SSLError unchanged (the 'except X: raise' clauses were no-ops). fenn.exceptions.NetworkError is documented as 'the remote host could not be reached', and the CLI (fenn run, fenn auth) only catches NetworkError / RemoteError -- so a DNS failure, refused connection or bad TLS cert to pyfenn.com surfaced as an unhandled requests traceback instead of a clean 'Remote error' message. Wrap both in NetworkError (keeping distinct 'Could not connect' / 'TLS error' wording), chaining the original with 'from exc'. Adds tests/unit/remote/test_client.py -- the first tests for RemoteClient. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uqJtTJWawYLVA5EdpUmho
Contributor
Author
|
The |
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
RemoteClient._requestwrapsrequests.exceptions.TimeoutasNetworkError, but re-raisesConnectionErrorandSSLErrorunchanged:The two
except X: raiseclauses are no-ops.fenn.exceptions.NetworkErroris documented as "The remote host could not be reached", and the CLI only handles the typed errors:fenn run—except RemoteError(NetworkErroris a subclass)fenn auth—except (NetworkError, RemoteError)So a DNS failure, refused connection, or bad TLS certificate when talking to
pyfenn.comescapes as a rawrequeststraceback instead of the intendedRemote error: ...message and clean exit.Fix
Wrap
ConnectionErrorandSSLErrorinNetworkErrortoo, keeping distinct wording (Could not connect to .../TLS error connecting to ...) and chaining the original withfrom exc.SSLErrorstays a separate clause (it's aConnectionErrorsubclass) so its message is kept.Tests
tests/unit/remote/test_client.py— the first tests forRemoteClient: transport errors (connection / SSL / connect-timeout / read-timeout) all raiseNetworkError; a 200 still returns; 401/402 still map toAuthError/InsufficientCreditsError. The connection/SSL/connect-timeout cases raise rawrequestsexceptions onmain.Verified:
pytest tests/unit— 924 passed;ruff check/formatandty check fenn/remote/client.pyclean. (Thepre-commitCI job is red on a pre-existingtyfailure infenn/experimental/vision/normalize.pyandfenn/logging.py, unrelated to this change.)