fix: return error instead of silently discarding writes when storage batch is None (M3)#604
Conversation
… None All write operations (put, put_aux, put_root, put_meta, delete, delete_aux, delete_root, delete_meta, commit_batch) on PrefixedRocksDbTransactionContext previously returned Ok(()) silently when self.batch was None, discarding the write without any indication to the caller. This could lead to silent data loss if a transactional context without a batch was mistakenly used for write operations. Now these methods return Error::StorageError when batch is None, making the failure explicit. Also fixes 4 merk tests that were unknowingly relying on the silent-discard behavior by providing a StorageBatch where writes are performed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #604 +/- ##
===========================================
+ Coverage 90.63% 90.69% +0.06%
===========================================
Files 182 182
Lines 49801 49966 +165
===========================================
+ Hits 45136 45318 +182
+ Misses 4665 4648 -17
🚀 New features to boost your workflow:
|
|
Okay makes sense |
Summary
PrefixedRocksDbTransactionContext(put,put_aux,put_root,put_meta,delete,delete_aux,delete_root,delete_meta,commit_batch) now returnError::StorageErrorwhenself.batchisNone, instead of silently returningOk(())StorageBatchNonebatchAudit finding M3: All write operations silently succeeded and discarded data when no batch was provided. No legitimate code path writes through a batchless context — all batchless call sites only perform reads. The silent success made it impossible for callers to detect data loss.
Test plan
test_write_operations_error_when_batch_is_none— verifies all 9 write operations return errorstest_read_operations_succeed_when_batch_is_none— verifies reads still work with None batch🤖 Generated with Claude Code