Preserve original session tenant on IEvent for AddGlobalProjection (#4270)#4280
Merged
jeremydmiller merged 1 commit intomasterfrom Apr 22, 2026
Merged
Conversation
StreamAction.TenantId's setter propagates to every IEvent on the stream. GlobalEventAppenderDecorator sets action.TenantId to the default tenant so AddGlobalProjection stores single-tenanted, but that also clobbered each event's TenantId to "*DEFAULT*". Inline SingleStreamProjection convention methods that read IEvent<T>.TenantId inside Create/Apply saw the default tenant instead of the session tenant the events were appended under. Capture action.TenantId before forcing default, then restore the original tenant on each IEvent. Event-row storage still routes to the default tenant (via action.TenantId), so the documented "global within conjoined tenancy" guarantee is unchanged. Fixes #4270. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 23, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StreamAction.TenantId's setter propagates the new tenant to everyIEventon the stream.GlobalEventAppenderDecoratorsetsaction.TenantId = *DEFAULT*soAddGlobalProjectionstores single-tenanted — but that side-effect also clobbered each event'sTenantId, so inlineSingleStreamProjectionCreate(IEvent<T>)/Apply(IEvent<T>, TDoc)convention methods read*DEFAULT*instead of the session tenant the events were appended under.IEvent. Storage is unchanged (mt_events / mt_streams still route to the default tenant viaaction.TenantId); the only behavior change is that in-flight event objects preserve the appending session's tenant.Fixes #4270.
Test plan
Bug_4270_global_projection_preserves_event_tenant— two facts, both now pass:event_tenant_id_is_preserved_in_create_apply_convention_methodsasserts@event.TenantId == "acme"(not*DEFAULT*) insideCreate/Apply.projection_storage_is_still_single_tenanted_after_fixasserts the projected document is reachable from the default-tenantQuerySession(proves the global-within-conjoined storage guarantee still holds).global_tenanted_streams_within_conjoined_tenancysuite (34 tests, inline + async + live + quick + rich append modes) still passes.🤖 Generated with Claude Code