[Issue #39] Handle malformed events during JetStream replay with proper error reporting #41
Reference in New Issue
Block a user
Delete Branch "issue-39-malformed-events"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #39
Summary
ReplayErrortype to capture malformed event details (sequence number, raw data, underlying error)ReplayResulttype to return both successfully parsed events and any errors encounteredEventStoreWithErrorsinterface for stores that can report replay errorsGetEventsWithErrorsonJetStreamEventStoreto give callers visibility into data qualityGetEventsto maintain backward compatibility (still skips malformed events silently)Impact
This addresses the silent data loss issue identified in the JetStream store. Callers can now:
GetEventsfor backward-compatible behavior (silent skip)GetEventsWithErrorsto receive information about any malformed eventsTest plan
ReplayErrortypeReplayResulttypeJetStreamEventStoreGenerated with Claude Code
Code Review - PR #41
Status: Approved
Summary
This PR introduces proper error handling for malformed events during JetStream replay, addressing Issue #39. The implementation is clean, well-documented, and maintains backward compatibility.
Strengths
1. Well-designed API
ReplayErrortype captures all necessary context (sequence number, raw data, underlying error)ReplayResultprovides a clean way to return both events and errorsEventStoreWithErrorsinterface allows type-safe detection of stores that support error reporting2. Backward Compatibility
GetEvents()continues to work as before (silently skips malformed events)GetEventsWithErrors()provides opt-in visibility into data quality issues3. Good Error Handling Pattern
Error()andUnwrap()methods4. Comprehensive Tests
ReplayErrorandReplayResulttypesMinor Observations (non-blocking)
ReplayResultlikeTotalCount()orSuccessRate()for monitoring use casesRawDatafield stores full message content - for very large corrupted messages this could use memory. A future enhancement might truncate or hash for logging purposes.Verdict
Solid implementation that solves the silent data loss problem. Ready to merge.
b630258f60toe77a3a9868