From 023a37b6f1765695a9cae308f353714facc9ba04 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Fri, 25 Sep 2026 20:16:19 -0700 Subject: [PATCH] Fall Back to the Default Search Path When PATH Is Unset The dotnet-leg test built its stand-in PATH from os.environ['PATH'], which raises KeyError in an environment without one, even though the skip check's shutil.which("bash") had already found bash through os.defpath. It now falls back to os.defpath, the same search path the skip check used, so bash and the stand-in's own tools still resolve. Raised by Copilot on the promotion PR #1850. Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/tests/test_release_guards.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/tests/test_release_guards.py b/scripts/tests/test_release_guards.py index 0ace2c87..6cbd9768 100755 --- a/scripts/tests/test_release_guards.py +++ b/scripts/tests/test_release_guards.py @@ -1072,7 +1072,10 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: verdict = run( ["bash", "-c", script], cwd=work, - env={**os.environ, "PATH": f"{bin_dir}{os.pathsep}{os.environ['PATH']}"}, + env={ + **os.environ, + "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", + }, capture_output=True, text=True, encoding="utf-8",