Include the offending path in file module directory errors#69691
Open
ggiesen wants to merge 2 commits into
Open
Include the offending path in file module directory errors#69691ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
The "A valid directory was not specified." SaltInvocationError raised by file.readdir and file.rmdir omitted the offending path, making template and highstate failures hard to diagnose. Include the path in the message. Fixes saltstack#47707
…d-dir errors The direct test calls file.rmdir with the exact argument shape the file.rmdir state uses (recurse=..., verbose=True, older_than=...), since verbose=True normally routes removal failures into the returned dict instead of raising, and proves the invalid-directory error still raises with the offending path in the message. The inverse tests guard against overcorrection: relative paths must still hit the untouched absolute-path check for both rmdir and readdir, and readdir on an existing directory must still return its listing without raising.
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.
What does this PR do?
file.readdir and file.rmdir raised a path-less "A valid directory was not specified." SaltInvocationError, making template/highstate failures hard to diagnose (issue #47707). The fix embeds the offending path in both messages (f-string with the local
pathvariable at salt/modules/file.py:4195 and :4345). Added two tests asserting the path appears in the message; verified both FAIL on unpatched code (via git stash of the source fix) and PASS with the fix. Full test file: 6 passed. Note: the shared venv's salt-factories log-server/event-listener plugins hang collection, so they were disabled with -p no: flags; shadow-import assert confirmed the worktree salt was under test.What issues does this PR fix or reference?
Fixes #47707
Previous Behavior
See #47707.
New Behavior
Include the offending path in file module directory errors. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).
Merge requirements satisfied?
Commits signed with GPG?
No