Keep the gateway connection when a tunnel fails to open - #60
Merged
Merged
Conversation
asyncssh reads the local login name for every client connection. A deployment can run the image as a uid with no passwd entry, and then the lookup raises ValueError. The error escaped connection_requested, thus asyncssh closed the whole caller connection. The image now sets LOGNAME, which getpass reads first. The docker-sbx provider turns a ValueError from asyncssh into ProviderTransportError, so the gateway fails only the channel. Fixes #59.
czpython
force-pushed
the
gateway-tunnel-failure
branch
from
September 28, 2026 09:03
fbe639c to
e12f902
Compare
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.
asyncssh reads the local login name for every client connection, also when the call gives
username. A deployment can run the image as a uid with no passwd entry, for exampleuser: 1000:1000to reach the sbx socket. Then the lookup raisesValueError. The error escapedconnection_requested, thus asyncssh closed the whole caller connection.asyncssh 2.24.0 has no option that sets the local name, so
open_gateway_tunnelcannot pass one. Thus the change has two parts:LOGNAME=appuser.getpassreadsLOGNAMEbefore it looks up the uid.DockerSbxProvider.open_gateway_tunnelturns aValueErrorfrom asyncssh intoProviderTransportError. The gateway already turns aProviderErrorintoChannelOpenError(OPEN_CONNECT_FAILED), so only the channel fails.The gateway still catches only
ProviderError. Providers translate their own failures at the boundary, and a defect in the gateway must not look like a connection failure.Validation:
uv run pytest: 739 passed on SQLite. Ruff, format checks, and Pyright passed.getpass.getuserraiseKeyError, as it does on Python 3.11 for a uid with no passwd entry.open_gateway_tunnelraisesProviderTransportError. Without the change, theValueErrorescapes.1000:1000, resolves the login name, and asyncssh builds its client options. WithLOGNAMEcleared, it fails withgetpwuid(): uid not found: 1000.A gateway that runs outside the image as a uid with no name still needs
LOGNAMEorUSERin its environment.Fixes #59.