Repository navigation
fix(cli): refuse a tree leaf that is already a directory - #1224
Merged
Merged
Conversation
Closes #1223. After #1222, show --diff and apply --dry-run still advertised a tree leaf as written when that path was already a directory, and the real apply exited 2 naming the tree root (`Is a directory`). apply --from silently nested the file at dest/alpha/alpha. _check_apply_paths now also refuses a produced path that exists as a real directory, so the four surfaces agree on `cannot write <leaf>: '<leaf>' is a directory, not a file` and write nothing.
Collaborator
Author
|
Review (Birfy) Tip SHA: d2b64b1
|
Birfy
enabled auto-merge (squash)
November 22, 2026 22:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1223.
Base: 5ac5548
Tip SHA: d2b64b1
What changed
#1222refuses a regular file sitting on the way to a tree leaf. The inverse hole was a directory sitting where the artifact wants a file:destis a directory,dest/alphais a directory, and the artifact writesalpha.show --diffandapply --dry-runadvertisedwritten: ["alpha"]while the realapplyexited 2 withcannot write <dest>: Is a directory(the tree root, not the blocking leaf).apply --fromwas worse:shutil.copy2nested the bytes atdest/alpha/alphaand reported success._check_apply_pathsnow also refuses a produced path that exists as a real directory, soshow --diff,apply --dry-run, the realapply,--from, and--install-toagree oncannot write <leaf>: '<leaf>' is a directory, not a fileand the preview still writes nothing. Existing#1221/#1215refusals and a sibling directory next toplain/written.mdare unchanged. A symlink at the leaf stays with the dest-link refusal.Red first
At this PR's base (
5ac55481) in a clean worktree with only the new test file present:The failing assertion is
assert show_errorintest_tree_leaf_blocked_by_a_directory_is_named_on_all_four_surfaces. The sibling-directory control was already green on live main; it stays as a lock.--fromexited 0 and advertisedwritten: ["alpha"];--install-toalready failed the real write but withcannot write <dest>: Is a directory.Ran at
d2b64b1fPYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_apply_blocked_leaf.py tests/test_apply_blocked_child.py tests/test_apply_blocked_parent.py tests/test_show_dest_refusals.py tests/test_write_dirs_apply_show.py tests/test_apply_symlink_dest.py tests/test_apply_noop.py tests/test_cli_apply_created_target.py tests/test_cli_apply_text_missing_parent.py tests/test_apply_backup_away_from_skills.py tests/test_apply_from.py tests/test_cli_write_error.py tests/test_skill_library_apply_install.py tests/test_demo_dest_link.py—94 passedpython -m tools.gen_api_docs --check—docs/api.md is up to datepython -m tools.changelog_fragments check—22 changelog fragment(s) OKNot run
mkdocs build --strictin its exact form: this host is offline and thesocialplugin fetchesfonts.google.com. The diff adds one sentence todocs/plugins.md; CIdocsis the line.