fix(dotfiles): tolerate a stale directory the deeper walk already removed - #12697
Conversation
…oved Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe cleanup loop now checks that each path is a directory before reading it. A new end-to-end test covers removal of nested stale links while preserving an unrelated link. ChangesDotfiles cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change prevents stale-directory cleanup from aborting when a deeper walk has already removed that directory, allowing the apply to finish and remove all stale links. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.) 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 |
Greptile SummaryThis PR prevents
Confidence Score: 5/5The PR appears safe to merge because the guard narrowly handles an already-removed directory and the regression test exercises the previously failing cleanup order. The changed cleanup preserves existing empty-directory behavior, avoids the known second visit to a removed parent, and is consistent with sibling cleanup implementations; no actionable regression remains. Important Files Changed
Reviews (1): Last reviewed commit: "fix(dotfiles): tolerate a stale director..." | Re-trigger Greptile |
Problem
A
symlink-eachentry fails withNo such file or directory (os error 2)on the apply that removes a source directory whose links sat at two depths, e.g. a skill directory holdingSKILL.mdandreferences/doc.md. The links are removed, the directories are removed, but the apply aborts, and every stale link after that entry in the same apply is left behind. The next apply succeeds.Reproduces on 2026.9.0 and main:
skills/nested/SKILL.mdandskills/nested/references/doc.mdexist, apply: clean.skills/nested/, commit, apply:No such file or directory (os error 2), exit 1.all files are applied.Deleting a flat directory (only
SKILL.md) is fine, so the trigger is the second depth.Cause
prune_stale_linkswalks each stale link's parent deepest first and climbs while the directory is empty. The walk fromreferences/doc.mdremovesreferences/and thennested/. The loop then visitsnested/again as the parent ofSKILL.mdand callsread_diron the directory it just removed.Fix
Break when the directory is already gone, using the same
!dir.is_dir() ||guard the two sibling walks in this file (cleanup_reconciled_directoriesand the unapply cleanup) already use.The added e2e case in
test_dotfiles_filesmirrors the scenario: two links at two depths under one directory, the directory removed, apply succeeds and the directory is gone. It fails on main with the error above and passes with the fix.cli/test_dotfiles_filespasses locally.Summary by CodeRabbit