Skip to content

refactor: log best-effort cleanup failures instead of swallowing them#78

Merged
bhekanik merged 1 commit into
mainfrom
refactor/log-non-fatal-cleanup-errors
Jun 11, 2026
Merged

refactor: log best-effort cleanup failures instead of swallowing them#78
bhekanik merged 1 commit into
mainfrom
refactor/log-non-fatal-cleanup-errors

Conversation

@bhekanik

@bhekanik bhekanik commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

Routes three best-effort cleanup calls in the mutation handler through a new log_non_fatal helper instead of discarding their errors with let _ = …. Audit backlog item P2 #19 (swallowed-error sweep). Off main.

Why

A silent cleanup failure hides real state drift:

  • a sent draft that fails to delete lingers in mxr drafts list;
  • an undo entry that fails to delete after a successful undo stays replayable until it expires;
  • an expired undo entry that fails to delete just accumulates.

None of these should abort the caller, but they shouldn't vanish either.

How

A small log_non_fatal(context, result) helper logs Err as a warn with context and otherwise does nothing. Applied to the three delete_undo_entry / delete_draft cleanups.

Scope note (honest)

The audit framed this as a broad sweep, but a survey of let _ = …await across the daemon found only these three are store writes whose failure is meaningful — the rest are genuine fire-and-forget (channel sends, broadcast, notify) that are correct to ignore. So the change is deliberately narrow rather than a blanket rewrite.

Verification

mxr daemon undo/mutation tests (95) pass; clippy + fmt clean. No user-facing contract change (internal observability), so no docs update.

Generated with Claude Code


Summary by cubic

Log best-effort cleanup failures in the mutation handler instead of swallowing them. Warnings now surface when deleting expired/spent undo entries or sent drafts fails, preventing silent state drift (lingering drafts or replayable undo IDs) while keeping these errors non-fatal.

Written for commit 72e2365. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error logging for background cleanup operations in data management workflows, improving system diagnostics and reliability without affecting user-facing functionality.

Three post-success cleanup calls in the mutation handler discarded their
errors with `let _ = …`: deleting a spent or expired undo entry, and
deleting a draft after it sends. None should abort the caller, but a
silent failure hides real state drift — a sent draft lingering in the
list, or an undo id that stays replayable until it expires.

Add a small `log_non_fatal` helper and route the three through it so the
failures surface as warnings with context instead of vanishing.
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mxr-mail Ready Ready Preview, Comment Jun 10, 2026 8:17pm

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa9cac03-f328-4d90-a99f-5465d2b95ba3

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb7a09 and 72e2365.

📒 Files selected for processing (1)
  • crates/daemon/src/handler/mutations.rs

📝 Walkthrough

Walkthrough

This PR introduces a log_non_fatal helper function to emit warnings when best-effort cleanup operations fail. The helper is then applied to three mutation cleanup sites: expired-undo deletion, post-success undo deletion, and draft deletion after send. Cleanup failures are now logged but do not affect operation success.

Changes

Non-fatal cleanup logging

Layer / File(s) Summary
log_non_fatal helper definition
crates/daemon/src/handler/mutations.rs
log_non_fatal is a generic helper that logs tracing::warn! when a best-effort Result is Err, preserving non-fatal cleanup semantics.
Apply logging to undo and draft cleanup
crates/daemon/src/handler/mutations.rs
Three cleanup sites in undo_mutation and send_stored_draft now call log_non_fatal(...) instead of silently discarding delete operation results, so deletion failures are warned about while the operations continue unaffected.

🎯 2 (Simple) | ⏱️ ~5 minutes

🐰 A helper hops through the code with care,
Warning us when cleanups fail to fare.
Three mutations now log their might,
Keeping best-effort work in sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: log best-effort cleanup failures instead of swallowing them' accurately and specifically describes the main change: adding logging for previously silent cleanup errors in mutation handlers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/log-non-fatal-cleanup-errors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@bhekanik bhekanik merged commit 54915ef into main Jun 11, 2026
25 of 27 checks passed
@bhekanik bhekanik deleted the refactor/log-non-fatal-cleanup-errors branch June 11, 2026 00:34
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.

1 participant