diff --git a/codeflash/code_utils/shell_utils.py b/codeflash/code_utils/shell_utils.py index 2052f3e96..1569b51a1 100644 --- a/codeflash/code_utils/shell_utils.py +++ b/codeflash/code_utils/shell_utils.py @@ -259,6 +259,10 @@ def get_cross_platform_subprocess_run_args( capture_output: bool = True, ) -> dict[str, str]: run_args = {"cwd": cwd, "env": env, "text": text, "timeout": timeout, "check": check} + # When text=True, use errors='replace' to handle non-UTF-8 bytes gracefully + # instead of raising UnicodeDecodeError + if text: + run_args["errors"] = "replace" if sys.platform == "win32": creationflags = subprocess.CREATE_NEW_PROCESS_GROUP run_args["creationflags"] = creationflags