Skip to content

Fix SFTPHookAsync letting a connection's known_hosts extra override an explicit constructor path - #73593

Merged
shahar1 merged 1 commit into
apache:mainfrom
namanjain24-sudo:fix-sftp-async-known-hosts-override
Sep 23, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
namanjain24-sudo:fix-sftp-async-known-hosts-override

Conversation

@namanjain24-sudo

Copy link
Copy Markdown
Contributor

_parse_extras() decided whether to take known_hosts from the connection's extra by comparing the already-expanded self.known_hosts against the literal, un-expanded "~/.ssh/known_hosts" default. Since __init__ always runs known_hosts through os.path.expanduser(), the two values can never be equal, so the comparison was always true: a connection-level known_hosts extra silently replaced even a path passed explicitly to the constructor.

SSHHookAsync gets this right elsewhere in the same file, by expanding the default before comparing and only falling back to the extra when the constructor was left at that default. This applies the same pattern to SFTPHookAsync.

closes: #73584


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

Generated-by: Claude Code (Sonnet 5) following the guidelines

…n explicit constructor path

_parse_extras() decided whether to take known_hosts from the connection's
extra by comparing the already-expanded self.known_hosts against the
literal, un-expanded "~/.ssh/known_hosts" default. Since __init__ always
runs known_hosts through os.path.expanduser(), the two values can never
be equal, so the comparison was always true: a connection-level
known_hosts extra silently replaced even a path passed explicitly to the
constructor.

SSHHookAsync gets this right elsewhere in the same file, by expanding the
default before comparing and only falling back to the extra when the
constructor was left at that default. This applies the same pattern to
SFTPHookAsync.
@shahar1
shahar1 merged commit 7dfa256 into apache:main Sep 23, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SFTPHookAsync lets a connection known_hosts extra override an explicit constructor path

2 participants