Skip to content

Fix silent flag in file.directory recurse (#60597)#69774

Open
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-60597
Open

Fix silent flag in file.directory recurse (#60597)#69774
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-60597

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the silent option of file.directory's recurse so that individual per-file and per-directory change notifications are actually suppressed.

In salt/states/file.py directory(), the silence marker (ret["changes"] = {"recursion": "Changes silenced"}) was assigned before the file.check_perms walk loop. Each check_perms call inside the loop mutates the same ret and repopulates ret["changes"], so the marker was immediately overwritten and every visited file/dir still showed up in the output. This PR moves the marker reset to just after the walk loop (and before the clean block, so clean's removed entries are preserved).

Note: the silent flag belongs inside recurse (for example recurse: [user, group, mode, silent]), not at the state top level.

What issues does this PR fix or reference?

Fixes #60597

Previous Behavior

With silent in the recurse set, file.directory still emitted a change notification for every file and directory touched by the recursive permission enforcement, instead of the single "Changes silenced" marker documented for silent.

New Behavior

With silent in the recurse set, ret["changes"] is {"recursion": "Changes silenced"} only. Any removed entries from a concurrent clean=True run are still reported. Runs without silent are unchanged and continue to report individual changes.

Merge requirements satisfied?

  • Docs: n/a (existing recurse/silent documentation already describes this behavior)
  • Changelog entry added (changelog/60597.fixed.md)
  • Tests written and described (in tests/pytests/unit/states/file/test_directory.py):
    • test_directory_recurse_silent_suppresses_changes_60597: production-shape call recurse=["mode", "silent"] with a walk yielding a child file and dir; asserts ret["changes"] == {"recursion": "Changes silenced"} (fails before the fix).
    • test_directory_recurse_without_silent_still_reports_changes_60597: must-not-regress; recurse=["mode"] still reports the child file/dir changes and never adds a recursion key.
    • test_directory_recurse_silent_preserves_clean_removed_60597: with clean=True, the silence marker and the removed entry coexist, verifying the reset runs before the clean block.

Commits signed with GPG? No

The silence marker for recurse was assigned before the check_perms walk
loop, so the per-file and per-dir change notifications gathered inside the
loop repopulated ret["changes"] and overrode it. Move the marker reset to
after the walk loop (but before the clean block, so removed entries are
preserved) so individual change notifications are suppressed as documented.

Fixes saltstack#60597
@ggiesen ggiesen requested a review from a team as a code owner July 10, 2026 17:56
@charzl charzl self-assigned this Jul 10, 2026
@dwoz dwoz added the test:full Run the full test suite label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants