From 22aa251d642e5c8013ce5db3fe0b513c26cf0470 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Jul 2026 16:30:38 +0000 Subject: [PATCH] Address code review: compute stderr_text only when chunks are present --- app/sovran_systemsos_web/server.py | 7 +++++-- app/tests/test_manual_backup_workflow.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/sovran_systemsos_web/server.py b/app/sovran_systemsos_web/server.py index 494d4af..d255171 100644 --- a/app/sovran_systemsos_web/server.py +++ b/app/sovran_systemsos_web/server.py @@ -3762,8 +3762,11 @@ async def _monitor_backup_subprocess(proc: asyncio.subprocess.Process) -> None: if status in {"SUCCESS", "FAILED"}: return - stderr_text = b"".join(stderr_chunks).decode("utf-8", errors="replace").strip() - detail = f" — stderr: {stderr_text}" if stderr_text else "" + detail = "" + if stderr_chunks: + stderr_text = b"".join(stderr_chunks).decode("utf-8", errors="replace").strip() + if stderr_text: + detail = f" — stderr: {stderr_text}" msg = f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] ERROR: Backup subprocess exited unexpectedly (code {rc}).{detail}" await loop.run_in_executor(None, _append_backup_log, msg) await loop.run_in_executor(None, _write_backup_status, "FAILED") diff --git a/app/tests/test_manual_backup_workflow.py b/app/tests/test_manual_backup_workflow.py index 27ada9d..35911c9 100644 --- a/app/tests/test_manual_backup_workflow.py +++ b/app/tests/test_manual_backup_workflow.py @@ -108,8 +108,10 @@ class ManualBackupWorkflowTests(unittest.TestCase): the FAILED log entry so the UI shows what went wrong (e.g. 'bash: not found') rather than only the raw exit code.""" source = SERVER_FILE.read_text() + self.assertIn("stderr_chunks", source) self.assertIn("stderr_text", source) - self.assertIn('if stderr_text else ""', source) + # stderr detail is conditionally appended only when non-empty + self.assertIn('detail = f" — stderr: {stderr_text}"', source) def test_exit_code_127_subprocess_stderr_drain(self): """Behavioral regression: a subprocess that exits 127 must have its