Skip to content

fix(cleanup): log WalkDir entry errors instead of silently skipping (#200)#244

Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:fix/cleanup-walkdir-error-logging-200
Closed

fix(cleanup): log WalkDir entry errors instead of silently skipping (#200)#244
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:fix/cleanup-walkdir-error-logging-200

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 29, 2026

Closes #200.

BatchedGlobPlanner::execute() walked cleanup roots with WalkDir and used let Ok(entry) = entry else { continue; } to discard iteration errors. Permission-denied entries, broken symlinks, and races where a tree got partially deleted mid-walk were skipped without a trace — a cleanup running under insufficient privileges (or against a half-removed shadow tree) would quietly miss files and the operator had no way to correlate the missed delete with the syscall failure.

Fix

Replace the silent let Ok(entry) = entry else { continue } with a match: on Err emit a debug log via the existing structured logger with the offending path (when WalkDir records it) and the io::Error message, then continue. The happy path is unchanged; walked_entries accounting still only increments on Ok.

Test plan

  • cargo build --manifest-path sdk/Cargo.toml — clean
  • cargo test --manifest-path sdk/Cargo.toml --lib policy::cleanup — 31/31 pass

TrueNine and others added 2 commits April 25, 2026 10:10
Fix two CI failures from previous merge
Closes TrueNine#200.

`BatchedGlobPlanner::execute()` walked the cleanup roots with
`WalkDir` and used `let Ok(entry) = entry else { continue; }` to
discard any iteration errors. Permission-denied entries, broken
symlinks, and races where a tree got partially deleted mid-walk
were skipped without a single trace, so a cleanup running under
insufficient privileges (or against a half-removed shadow tree)
would quietly miss files and the operator had no way to correlate
the missed delete with the underlying syscall failure.

Replace the silent continue with a `match`: on `Err` emit a
`debug` log via the existing structured logger with the offending
path (when `WalkDir` records it) and the `io::Error` message,
then fall through to `continue` so behaviour is unchanged for the
happy path. Operators tailing the cleanup logs now see exactly
which entries were skipped and why; tests' `walked_entries`
accounting is unaffected since the increment still only fires on
`Ok(entry)`.

`cargo test --lib policy::cleanup` is green (31/31).
@SAY-5 SAY-5 requested a review from TrueNine as a code owner April 29, 2026 22:23
@TrueNine TrueNine changed the base branch from main to dev April 30, 2026 08:08
@TrueNine
Copy link
Copy Markdown
Owner

Merged into dev via cherry-pick. The PR base was changed from main to dev, which caused conflicts because dev had diverged significantly. All commits have been cherry-picked onto dev and pushed. Thanks for the contributions!

@TrueNine TrueNine closed this Apr 30, 2026
@TrueNine
Copy link
Copy Markdown
Owner

Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cleanup] WalkDir 错误静默吞没

2 participants