Repository navigation
Refuse a Local Instruction Path Whose Parent Is a File - #2429
Conversation
lstat raises NotADirectoryError where a parent component of the local instruction path is a regular file, such as an absolute XDG_CONFIG_HOME pointing at one, and that was read as an absent local file, so the configured text was dropped silently. Only a missing path is absent now, and anything else is refused as unreadable with nothing changed. Refs #2423 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Windows raises FileNotFoundError rather than NotADirectoryError for a path whose parent is a file, so the refusal is POSIX-only and the case skips there like its POSIX-only neighbours. Refs #2423 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2429 +/- ##
========================================
Coverage 58.47% 58.47%
========================================
Files 16 16
Lines 8062 8062
========================================
Hits 4714 4714
Misses 3348 3348
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Windows file-parent paths may still be silently skipped, and the regression test does not exercise its documented XDG_CONFIG_HOME case.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR hardens local instruction loading so invalid parent paths are not silently ignored.
Changes:
- Treats only missing paths as absent.
- Adds POSIX regression coverage for file-parent paths.
| File | Summary |
|---|---|
host-setup/agent-safety/claude/install.py |
Refines local path error handling. |
host-setup/agent-safety/claude/test_install.py |
Tests refusal for invalid parent paths. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
## Summary Promotes `develop` to `main` with four pull requests, each already reviewed and merged into `develop`: - [#2424](#2424) Render the Whole Global CLAUDE.md and Back Up a Hand Edit. - The host-safety installer now owns all of `~/.claude/CLAUDE.md`. It renders a header, the two existing blocks, and a shared host-local file, `agent-fleet/local.md`. - It replaces an earlier render silently. A file edited by hand, or one written before this change, is copied to a timestamped `.bak` first. - `merge-and-release` step 7 now also runs this kit's `--report`, so a release flags a stale host. - [#2427](#2427) Render CLAUDE.md First and Let the Real Write Be the Check, the fix for this PR's Copilot finding. - [#2428](#2428) Read the Local Instruction File Only When It Is a Regular File, the fix for this PR's previously-missed Copilot finding. - [#2429](#2429) Refuse a Local Instruction Path Whose Parent Is a File, the fix for this PR's third-round Copilot finding. On a host's next install, the existing `CLAUDE.md` is backed up and replaced. Anything host-specific moves into the local file. Closes #2423 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Summary
This fixes the third-round Copilot finding on promotion PR #2425.
read_local_instructionstreatedNotADirectoryErrorfromlstatas "no local file". That error comes up when a parent component of the local instruction path is a regular file, for example an absoluteXDG_CONFIG_HOMEpointing at a file. The configured local text was then dropped silently. Now only a missing path counts as absent. Anything else is refused as "cannot be read", and nothing is installed.Deliberate behavior:
~/.configitself is a regular file, even though nothing was configured. That is a broken home directory, so a loud refusal that names the path is preferred over silently skipping.lstatraisesFileNotFoundErrorfor a file parent, so the path still reads as absent there, and the new case skips on non-POSIX like its neighbors. I haven't confirmed this on Windows.Refs #2423
Verification
python3 -m unittest test_install: 124 tests OK on 3.13, and the edge cases also pass on 3.14.🤖 Generated with Claude Code