Skip to content

Fall Back to the Default Search Path When PATH Is Unset - #1859

Merged
ptr727 merged 1 commit into
developfrom
fix/dotnet-leg-test-path-default
Sep 26, 2026
Merged

ptr727 merged 1 commit into
developfrom
fix/dotnet-leg-test-path-default

Conversation

@ptr727

@ptr727 ptr727 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Fixes a finding Copilot raised on the promotion PR #1850, against #1848's test.

test_validator_dotnet_leg_fails_when_no_report_was_written built its stand-in PATH from os.environ['PATH'], which raises KeyError when PATH is unset. The test's skip check doesn't catch that case: with PATH unset, shutil.which("bash") searches a default path (os.confstr("CS_PATH"), else os.defpath), finds bash, and lets the test run. The test now falls back to os.defpath, so both the subprocess's bash and the stand-in's /usr/bin/env bash resolve.

With PATH set to an empty string the test is skipped, before and after this change, because shutil.which returns nothing for an empty PATH.

Verification: under env -u PATH, the base commit fails with KeyError in each of the four subtests, and the head passes. The suite passes with PATH set. One local strict review pass is recorded. It raised only the wording of the commit message's search-path claim, which this description corrects.

🤖 Generated with Claude Code

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) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 26, 2026 03:17
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 58193282-4f5f-4b84-b54f-2d08fedfe33a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change safely eliminates a KeyError when PATH is unset without altering the intended test behavior.

Review effort: Lite
Findings: None

What changed in this PR

This PR fixes a robustness bug in the release-guards test suite where test_validator_dotnet_leg_fails_when_no_report_was_written could raise KeyError when PATH is unset, by falling back to a default search path when constructing the subprocess environment.

Changes:

  • Replace direct access to os.environ["PATH"] with a safe fallback via os.environ.get("PATH", os.defpath) when building the subprocess PATH.
File Description
scripts/​tests/​test_release_guards.py Avoids KeyError by safely defaulting PATH for the subprocess env when PATH is unset.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ptr727
ptr727 merged commit e9c8df0 into develop Sep 26, 2026
9 checks passed
@ptr727
ptr727 deleted the fix/dotnet-leg-test-path-default branch September 26, 2026 03:20
ptr727 added a commit that referenced this pull request Sep 26, 2026
…1863)

Fixes a finding Copilot raised on the promotion PR #1850, against
#1846's test.

`EndToEndCase.run_configure` puts a `gh` stub first on a `PATH` built
from `os.environ.get('PATH', '')`. With `PATH` unset, `require("bash",
"jq")` still finds both tools through the default search path, but the
copied `configure.sh` then runs with only the stub directory on its
`PATH` and can't find `jq`. The fallback is now `os.defpath`, matching
the dotnet-leg test's fix in #1859. With `PATH` set to an empty string,
`require()` skips the case, so nothing changes there.

Verification: under `env -u PATH`, the base commit fails two tests and
the head passes all seven. The suite passes with `PATH` set. One local
strict review pass is recorded, with no findings.

Three older harnesses use the same empty fallback in files this
promotion doesn't touch. They're filed as #1862.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
ptr727 added a commit that referenced this pull request Sep 26, 2026
…and Overnight Fixes to Main (#1850)

Promotes `develop` to `main`.

## Carried

- #1846: exits `repo-config/configure.sh` early, writing nothing, for a
repository whose registry `status` is `archived`.
- #1848: fails the validator's C# unit test step when the run wrote no
non-empty Cobertura report, clearing `./coverage` first. It declines
#1134's `ref` input with evidence, since a bare checkout already
validates `github.sha`, and D1.2 now says so. #1134's third gap moved to
#1800.
- #1851: asserts that the two planted registration defects are
themselves reported.
- #1854, #1858: correct #1846's test docstrings, which claimed the
script makes no `gh` call before the archived check in cases where it
does. Raised by Copilot on this pull request.
- #1856: passes `--repo` on documented handoff commands and guards
handoff reads against a full page, per #1847.
- #1859, #1863: fall back to the default search path when `PATH` is
unset in #1848's and #1846's test harnesses. Raised by Copilot on this
pull request.
- #1861: scopes `VerifyReferenceAotCompatibility` to an AOT publish in
`dotnet-codestyle`, per #1857.
- #1867: establishes the `PATH` order `tool_shadow_path` names, per
#1644.
- #1870: makes the installer's dirty-checkout tests independent of the
real checkout's state, per #1641.
- #1873: pins and decodes git's quoting in `repo_gate.py`'s `ls-files`
read, per #1580 and #1872.
- #1878: folds typographic punctuation in `pr_review.py reply --match`,
per #1299.
- #1883: routes `configure.sh`'s `ruleset_id()` through `jqr`, per
#1253.
- #1885: states the pin comment as the release tag and defines `$/`, per
#1805.
- #1888: distinguishes `./` from `$/` resolution in the pin rule's
prose, per #1886.
- #1893: drops the issue reference from `repo-config/README.md`'s
archived-exemption note, which Copilot flagged on six rounds of this
pull request.
- #1895: describes IL3058 in `dotnet-codestyle` as a referenced assembly
lacking `IsAotCompatible` metadata set to `true`, and drops the
unversioned package examples. Raised by CodeRabbit on this pull request.

Callers that pin a hub release get the new C# check on their next pin
bump. A test project that runs `dotnet test --coverage` without writing
a report now fails its step rather than passing silently.

Closes #1134
Closes #1847
Closes #1857
Closes #1644
Closes #1641
Closes #1580
Closes #1872
Closes #1299
Closes #1253
Closes #1805
Closes #1886

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Backlog counts and rankings now consistently exclude handoff issues,
including those also marked blocked.
* Repository configuration commands now exit without writing when a
repository is archived.
* Review-thread matching handles typographic punctuation, and no-match
responses report the unresolved-thread count.
* Tool setup handles PATH entries more precisely, and repository checks
report unusual file paths without crashing.

* **Reliability**
* Validation now fails when C# or Python tests produce no coverage
report.
  * Agent setup can use an explicit dirty-checkout override.
* Workflow and repository guidance clarifies reference resolution,
release-tag pinning, and AOT configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants