Skip to content

Handle null link-to events from deleted/scavenged streams#185

Merged
joshkempner merged 1 commit into
masterfrom
condron/null-linkto-handling
Mar 19, 2026
Merged

Handle null link-to events from deleted/scavenged streams#185
joshkempner merged 1 commit into
masterfrom
condron/null-linkto-handling

Conversation

@condron
Copy link
Copy Markdown
Contributor

@condron condron commented Mar 18, 2026

Closes #189

Summary

When EventStore resolves link events against deleted or scavenged streams, the resolved Event property is null while the link event retains its position. Stream positions are immutable, so downstream checkpoints remain valid.

Changes

Null event guards (EventStoreConnectionWrapper.cs)

  • ToRecordedEvents: skips null entries when converting ResolvedEvent[] to RecordedEvent[]
  • Subscription callbacks (SubscribeToStream, SubscribeToStreamFrom, SubscribeToAll, SubscribeToAllFrom): check evt.Event != null before invoking eventAppeared

Deserialize guard (JsonMessageSerializer.cs)

  • Returns null for events with null/empty Metadata or Data instead of throwing during JObject.Parse

TcpBus port-collision fix

  • Replaced hardcoded port 10008 with dynamic GetFreePort() in TcpBusClientSideTests and TcpBusServerSideTests to prevent failures when net8.0 and net10.0 tests run in parallel

Tests

  • when_handling_null_link_to_events: 5 tests covering null-skipping and event number preservation in ToRecordedEvents
  • when_deserializing_null_or_empty_event_data: 5 tests covering null/empty metadata and data in Deserialize

Documentation

  • Inline XML doc comments on ToRecordedEvents and Deserialize
  • Standalone doc: Docs/null-linkto-handling.md

Code formatting

  • dotnet format applied solution-wide (separate commit)

@condron condron requested a review from a team as a code owner March 18, 2026 18:51
Copy link
Copy Markdown
Contributor

@joshkempner joshkempner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the reformatting commit and do that in a separate PR with an editorconfig file that we agree on.

Comment thread src/build.props Outdated
Comment thread src/ReactiveDomain.Foundation/StreamStore/JsonMessageSerializer.cs
Comment thread Docs/null-linkto-handling.md
@condron condron force-pushed the condron/null-linkto-handling branch from 5081bb3 to 5a2afd5 Compare March 19, 2026 15:33
@condron condron force-pushed the condron/null-linkto-handling branch from 6733cdd to 00aec18 Compare March 19, 2026 18:22
@joshkempner joshkempner merged commit 867a907 into master Mar 19, 2026
2 checks passed
@joshkempner joshkempner deleted the condron/null-linkto-handling branch March 19, 2026 18:26
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.

Handle null link-to events in subscriptions and batch reads

2 participants