fix(storage): guard prepare timestamp serialization#420
Conversation
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview In-memory event writes use Tests and fixtures are updated to pass explicit UTC Reviewed by Cursor Bugbot for commit 93b637f. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (3)
Walkthrough
ChangesTimestamp validation and UTC propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs (1)
29-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate "now" constants risk drift.
EffectiveNowandEffectiveNowRecordTimestampencode the same instant but with differentDateTimeKind. Consider deriving one from the other (e.g.,EffectiveNow = DateTime.SpecifyKind(EffectiveNowRecordTimestamp, DateTimeKind.Unspecified)) so a future edit to the literal date doesn't desynchronize the two.♻️ Proposed consolidation
- public static DateTime EffectiveNow { get; } = new DateTime(2022, 1, 5, 00, 00, 00); - private static DateTime EffectiveNowRecordTimestamp { get; } = new DateTime(2022, 1, 5, 00, 00, 00, DateTimeKind.Utc); + private static DateTime EffectiveNowRecordTimestamp { get; } = new DateTime(2022, 1, 5, 00, 00, 00, DateTimeKind.Utc); + public static DateTime EffectiveNow { get; } = DateTime.SpecifyKind(EffectiveNowRecordTimestamp, DateTimeKind.Unspecified);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs` around lines 29 - 39, Duplicate "now" constants should be consolidated to avoid drift. In StreamMetadatas, keep a single source of truth for the shared instant by deriving EffectiveNow from EffectiveNowRecordTimestamp (or vice versa) using the desired DateTimeKind, and update any dependent helpers like ScavengePointRec to use that shared value consistently. This ensures future edits to the literal date can’t desynchronize the two properties.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs`:
- Around line 29-39: Duplicate "now" constants should be consolidated to avoid
drift. In StreamMetadatas, keep a single source of truth for the shared instant
by deriving EffectiveNow from EffectiveNowRecordTimestamp (or vice versa) using
the desired DateTimeKind, and update any dependent helpers like ScavengePointRec
to use that shared value consistently. This ensures future edits to the literal
date can’t desynchronize the two properties.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 84b9b015-97d6-467c-987c-e33e26d48bfb
📒 Files selected for processing (5)
src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cssrc/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cssrc/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cssrc/EventStore.Core/Services/Storage/InMemory/SingleEventInMemoryStream.cssrc/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 93b637f. Configure here.
| Assert.AreEqual(c.CorrelationId, _eventId); | ||
| Assert.AreEqual(c.TransactionPosition, 4321); | ||
| Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21)); | ||
| Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc)); |
There was a problem hiding this comment.
Commit read expects UTC kind
Medium Severity
The round-trip commit test now expects TimeStamp with DateTimeKind.Utc, but CommitLogRecord still builds timestamps from disk ticks without setting UTC kind, so the value read back can remain Unspecified even when ticks match.
Reviewed by Cursor Bugbot for commit 93b637f. Configure here.


Uh oh!
There was an error while loading. Please reload this page.