From bf7ba133eb99aea2f6e462d89dd5727f3c32540d Mon Sep 17 00:00:00 2001 From: Harshit Sharma <66710144+harshitethic@users.noreply.github.com> Date: Tue, 22 Sep 2026 03:20:36 +0530 Subject: [PATCH 1/2] fix: normalize timed-out command output --- backend/app/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 359c165..1496b81 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -68,8 +68,10 @@ def run(cmd: list[str], cwd: Path, timeout: int = 120) -> tuple[int, str]: ) return proc.returncode, proc.stdout except subprocess.TimeoutExpired as exc: - out = (exc.stdout or "") + "\n[command timed out]" - return 124, out + out = exc.stdout or "" + if isinstance(out, bytes): + out = out.decode(errors="replace") + return 124, f"{out}\n[command timed out]" def safe_repo_name(url: str) -> str: From 40d9163eb3c85b3d740f01aa4f62c6c6df5ee650 Mon Sep 17 00:00:00 2001 From: Harshit Sharma <66710144+harshitethic@users.noreply.github.com> Date: Tue, 22 Sep 2026 03:20:39 +0530 Subject: [PATCH 2/2] test: cover bytes output on subprocess timeout --- backend/tests/test_main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/tests/test_main.py b/backend/tests/test_main.py index c20cdb5..76c9223 100644 --- a/backend/tests/test_main.py +++ b/backend/tests/test_main.py @@ -1,5 +1,6 @@ import asyncio import os +import subprocess import tempfile import unittest from pathlib import Path @@ -14,6 +15,7 @@ github_headers, health, parse_json_object, + run, safe_branch_name, safe_repo_name, workspace_repo, @@ -138,6 +140,18 @@ def test_run_request_rejects_invalid_iteration_count(self) -> None: max_iterations=0, ) + def test_run_handles_bytes_output_from_timeout(self) -> None: + timeout = subprocess.TimeoutExpired( + cmd=["python", "-m", "pytest"], + timeout=1, + output=b"partial output", + ) + with patch("app.main.subprocess.run", side_effect=timeout): + code, output = run(["python", "-m", "pytest"], Path("."), timeout=1) + + self.assertEqual(code, 124) + self.assertEqual(output, "partial output\n[command timed out]") + def test_health_contract(self) -> None: self.assertEqual( asyncio.run(health()),