fix: decode SSH subprocess output tolerantly - #37265
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The reported initialization failure is still present on current main: tools/environments/ssh.py:149 (and six sibling direct calls) uses text=True with captured output but no tolerant decoding.
Problems
tests/tools/test_ssh_environment_decoding.py:31depends on the old one-line call layout. Current main formats every relevant call across multiple lines, such astools/environments/ssh.py:104-110and149-155, so this scan would produce no snippets after salvage even if the implementation is correct.- The direct
subprocess.runscope leavesSSHEnvironment._run_bash(tools/environments/ssh.py:353) delegating to_popen_bash, whosePopen(..., text=True)attools/environments/base.py:146-152still has no encoding/error parameters. Please explicitly decide whether that execution path belongs in this bug class.
Suggested changes
- Apply the seven kwargs changes to the current multiline calls and replace the source-layout assertion with behavior-oriented subprocess tests.
- If execution output is in scope, cover
_popen_bash; otherwise narrow the stated guarantee to direct SSH/scp setup and sync calls.
Automated hermes-sweeper review.
| def test_ssh_subprocess_text_captures_all_use_tolerant_decoding(): | ||
| source = ssh_env.Path(ssh_env.__file__).read_text(encoding="utf-8") | ||
| snippets = [ | ||
| line for line in source.splitlines() |
There was a problem hiding this comment.
This only recognizes one-line subprocess.run(..., capture_output=True, text=True) calls. Current main formats all seven relevant SSH calls across multiple lines, so this test would find no snippets after salvage even when the decoding kwargs are present. Please use a behavior-oriented test or a layout-independent inspection.
|
Closing as superseded by merged #70875. That PR covers the SSH subprocess decoding sites and adds repository-wide enforcement. This branch remains intact for reference. |
This PR is obsolete and is being closed. The subprocess text-decoding bug class, including the SSH call sites changed here, landed on
mainthrough #70875.Why this PR is being closed
text=Truesubprocess sweep and added a CI linter against regressions.tools/environments/ssh.pyis included in that merged scope.main; rebasing it would duplicate the merged implementation.Where the maintained change lives
0f732cb3d6b11dc903ca4303ef2cabd99cbe0adcf8dde9aa89b55e4c5d0b7ecb35f1ea1570f9f0e4Closing this PR unmerged. The branch is left intact for reference.