Skip to content

fix(client): record sync summary and flush telemetry on delete failure - #126

Open
markusbrand wants to merge 1 commit into
masterfrom
fix/sync-delete-failure-telemetry-summary
Open

markusbrand wants to merge 1 commit into
masterfrom
fix/sync-delete-failure-telemetry-summary

Conversation

@markusbrand

Copy link
Copy Markdown
Owner

Summary

When the desktop client synchronization engine encountered an error while deleting a remote file on the server (e.g., HTTP 403, 500, or network disconnect), it queued a DiagnosticEventPayload and terminated run_sync with return Err(...). However, unlike the list_files failure path or the normal completion path, it omitted enqueue_sync_summary and flush_telemetry_queue(client).

Consequently:

  1. No SyncSummary record was ever generated or persisted for the failed sync cycle.
  2. The queued DiagnosticEvent remained stuck in the local offline file buffer and was never flushed.
  3. Server dashboards and brandybox doctor remained completely unaware of sync failures occurring during remote file deletion.

Changes

  • In client-tauri/src-tauri/src/sync.rs, when client.delete_file(path) fails:
    • Enqueue a SyncSummaryPayload with status: "failed", failure_count: 1, elapsed duration_ms, total scanned file count (local_list.len() + remote_list.len()), and error details in error_summary_json.
    • Call flush_telemetry_queue(client) before returning the error.
  • In client-tauri/src-tauri/src/config.rs and credentials.rs, export and use a shared ENV_MUTEX for unit tests to ensure thread-safe environment variable isolation during parallel test execution.
  • Add regression test test_sync_delete_failure_records_summary_and_flushes_telemetry in client-tauri/src-tauri/src/sync.rs to reproduce and verify the fix.
  • Add OpenSpec change tracking and specs in openspec/changes/fix-sync-delete-failure-telemetry-summary/.

Verification

  • Reproduced failure prior to fix: test panicked with Expected 1 SyncSummaryPayload enqueued on delete failure (left: 0, right: 1).
  • Verified after fix: cargo test passes all 22 tests.
  • Verified frontend web build (npm run build in web) and docs build (mkdocs build) succeed.

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