Skip to content

Conversation

@matt-ramotar
Copy link
Collaborator

@matt-ramotar matt-ramotar commented Jan 11, 2026

Closes #722

Problem

MutableStore.write() returned StoreWriteResponse.Success even when SourceOfTruth.write() failed, causing silent data loss. Callers received explicit success while their data was never persisted.

Root Cause

SourceOfTruthWithBarrier.write() caught exceptions from the delegate but only propagated errors to readers via the barrier mechanism. It never surfaced errors back to write callers. Consequently, RealStore.write() always returned StoreDelegateWriteResult.Success.

Solution

Changed SourceOfTruthWithBarrier.write() to return SourceOfTruth.WriteException? instead of Unit. This enables:

  • RealStore.write() to check the return value and return appropriate StoreDelegateWriteResult
  • RealMutableStore to surface write errors to callers
  • FetcherController to continue working unchanged (ignores return value)
  • Barrier-based error notification to readers to continue working as before

Note

Fixes silent data loss by propagating SourceOfTruth write failures and gating follow-up actions.

  • Change SourceOfTruthWithBarrier.write to return SourceOfTruth.WriteException?; still emits barrier error to readers
  • Update RealStore.write to interpret the new return value and only cache on success, returning StoreDelegateWriteResult.Error on failure
  • Update RealMutableStore write flow to proceed to network only if the local write succeeds; surface local write errors as StoreWriteResponse.Error
  • Tests: add cases for SOT write failure propagation, ensuring no network call and no mem-cache update; allow TestStore to use sourceOfTruth = null; track postCallCount in TestUpdater

Written by Cursor Bugbot for commit f12f175. This will update automatically on new commits. Configure here.

Signed-off-by: Matt Ramotar <[email protected]>
@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

❌ Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.21%. Comparing base (d4e94b4) to head (f12f175).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...vefoundation/store/store5/impl/RealMutableStore.kt 66.66% 2 Missing and 3 partials ⚠️
...ilenativefoundation/store/store5/impl/RealStore.kt 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #727      +/-   ##
==========================================
+ Coverage   79.17%   79.21%   +0.04%     
==========================================
  Files          42       42              
  Lines         941      919      -22     
  Branches      169      174       +5     
==========================================
- Hits          745      728      -17     
+ Misses        120      116       -4     
+ Partials       76       75       -1     
Files with missing lines Coverage Δ
...tion/store/store5/impl/SourceOfTruthWithBarrier.kt 97.50% <100.00%> (+1.15%) ⬆️
...ilenativefoundation/store/store5/impl/RealStore.kt 89.84% <80.00%> (+1.12%) ⬆️
...vefoundation/store/store5/impl/RealMutableStore.kt 76.29% <66.66%> (-1.08%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Matt Ramotar <[email protected]>
@matt-ramotar matt-ramotar merged commit cfb4ae0 into main Jan 11, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in Store Roadmap Jan 11, 2026
@matt-ramotar matt-ramotar deleted the matt-ramotar/722/fix branch January 11, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] MutableStore.write reports success when SourceOfTruth writer throws

2 participants