fix(ssh): replace private _username with public get_extra_info API#408
Open
xingyug wants to merge 1 commit intorhel-lightspeed:mainfrom
Open
fix(ssh): replace private _username with public get_extra_info API#408xingyug wants to merge 1 commit intorhel-lightspeed:mainfrom
xingyug wants to merge 1 commit intorhel-lightspeed:mainfrom
Conversation
Replace all usages of asyncssh's private `conn._username` attribute
with the public `conn.get_extra_info('username')` API. This decouples
us from asyncssh's internal implementation details and prevents
potential breakage on future asyncssh upgrades.
5 occurrences replaced in ssh.py, corresponding test mocks updated.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
For team members: test commit |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Summary
Replace all usages of asyncssh's private
conn._usernameattribute with the publicconn.get_extra_info("username")API.Motivation
The codebase accesses
SSHClientConnection._usernamein 5 places for audit logging and error messages. This is a private attribute (prefixed with_) that is not part of asyncssh's public API contract. While it works today, it could break on any future asyncssh release without notice.asyncssh provides
get_extra_info("username")as the documented public API for retrieving the authenticated username. It returns the same value — verified to be the exact same object (isidentity) in testing.Changes
src/linux_mcp_server/connection/ssh.py(5 replacements):get_remote_bin_path()SSH error message (L325)get_remote_bin_path()not-found error message (L330)Tests (3 files, mock pattern updated):
Verification
make verifypasses (ruff ✅, pyright ✅, 487 tests ✅)get_extra_info("username")returns identical results to_usernameacross multiple scenarios (explicit username, SSH config inferred username)