From 413b9a107411ba3b335be5825287867daeedefe2 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Wed, 18 Nov 2026 15:43:28 +0800 Subject: [PATCH] fix(webui): recognize missing Python from Windows sshd exit 1 --- nanobot/webui/remote_ssh.py | 10 +++++++--- tests/webui/test_remote_instances.py | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/nanobot/webui/remote_ssh.py b/nanobot/webui/remote_ssh.py index df0adf639..5631bceae 100644 --- a/nanobot/webui/remote_ssh.py +++ b/nanobot/webui/remote_ssh.py @@ -159,10 +159,14 @@ async def run_check( await stop_process(process) if process.returncode == 0: break - # Missing command: POSIX 127, cmd.exe 9009 (truncated to 49 - # by POSIX SSH clients), or PowerShell's exception marker. + # Windows sshd may report a missing command as 1. Match the + # quoted executable in cmd.exe's diagnostic, not its language. + first_line = stderr.partition(b"\n")[0] if not sudo and (process.returncode in {49, 127, 9009} or ( - process.returncode == 1 and b"CommandNotFoundException" in stderr + process.returncode == 1 and ( + b"CommandNotFoundException" in stderr + or any(f"{quote}{executable}{quote}".encode() in first_line for quote in ("'", '"')) + ) )): continue error = ssh_error(stderr) diff --git a/tests/webui/test_remote_instances.py b/tests/webui/test_remote_instances.py index afca36947..e8c79b513 100644 --- a/tests/webui/test_remote_instances.py +++ b/tests/webui/test_remote_instances.py @@ -1045,6 +1045,8 @@ async def test_probe_ignores_shell_banners_without_exposing_them(monkeypatch, ba @pytest.mark.parametrize(("returncode", "stderr", "expected_error"), [ (127, b"python3: not found", ""), (49, b"'python3' is not recognized as an internal or external command", ""), + (1, b"'python3' is not recognized as an internal or external command", ""), + (1, '"python3" 不是内部或外部命令'.encode(), ""), (1, b"FullyQualifiedErrorId : CommandNotFoundException", ""), (255, b"Permission denied (publickey).", "ssh_auth_failed"), (1, b"Traceback (most recent call last):", "probe_failed"),