fix: skip bash syntax validation on Windows - #30
Conversation
_validate_bash_command calls /bin/bash -n, which is absent on Windows. This causes FileNotFoundError (or exit code 1) on every agent step, raising FormatError for every valid command. Guard the subprocess call with a sys.platform check and return early on win32.
|
Confirming this PR is needed, and reporting a second Windows blocker that sits immediately behind it. Environment: Windows Server 2016, Python 3.13, Git Bash, environment.shell set to C:\Program Files\Git\bin\bash.exe. With this PR applied, _validate_bash_command no longer raises FileNotFoundError — but every command then fails at execution with returncode 127: /usr/bin/bash: Files\Git\bin\bash.exe: No such file or directory Cause. environments/local_workspace.py runs commands as: subprocess.run(command, shell=True, executable=self.config.shell, ...)
CompletedProcess(args='ls', returncode=126, stdout='', stderr='/c: /c: Is a directory\n') Suggested fix — invoke the shell directly instead of via shell=True: result = subprocess.run( if shell: With this PR plus that change, the harness runs end-to-end on Windows and completes tasks normally. Happy to open a separate PR for the local_workspace.py change if that's preferred. |
Problem
_validate_bash_commandinbase.pycalls/bin/bash -nto syntax-check each agent action. On Windows,/bin/bashdoes not exist, sosubprocess.runraisesFileNotFoundError. This propagates as an unhandled exception on every agent step, preventing Webwright from running on Windows at all.Fix
Guard the
subprocess.runcall withsys.platform == "win32"and return early. On Windows the command is passed through without syntax validation; on POSIX the existing behavior is preserved exactly.Changes
src/webwright/models/base.py— addedimport sys; added aif sys.platform == "win32": returnguard at the top of_validate_bash_commandtests/unit/test_bash_validation.py— four new tests: valid command on POSIX, invalid syntax raisesValueErroron POSIX, validation is skipped on Windows, andsubprocess.runis never called on WindowsNot affected
/bin/bash -nis still called and errors still raiseValueErrorbase.py— not touched