Pin unregistered-tenant MT002 behavior under UseTenantPartitionedEvents (GH-3021)#3031
Merged
Merged
Conversation
…-3021 investigation) Resolves the #3021 Phase-1 "Investigate: an append for a never-registered tenant via InvokeForTenantAsync did not surface MT002 (possible silent misroute)" item. Finding: it is NOT a silent misroute. An append for a tenant never registered via AddMartenManagedTenantsAsync raises Marten's managed-partition guard MT002 ("Tenant 'x' has no registered partition") as a MartenCommandException, on both the Wolverine handler path and a direct session, and nothing is written to any partition. The original observation was a downstream symptom of GH-3025: the foundational harness's StartTally handler returns a single MartenOps.StartStream, which pre-3025 was silently dropped (no SaveChangesAsync) — so the append never reached Postgres and MT002 never fired. With GH-3025 fixed (6.4.4) the append executes and MT002 surfaces. Test-only. Confirmed the new test fails (no exception — the original silent symptom) when the GH-3025 fix is reverted, and passes with it, so it guards both the single-IMartenOp persistence and the managed-partition guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closed
17 tasks
This was referenced Jun 8, 2026
Merged
This was referenced Jun 11, 2026
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.
Advances #3021 Phase 1 — resolves the flagged investigation item:
Finding: not a silent misroute
An append for a tenant that was never registered via
AddMartenManagedTenantsAsyncraises Marten's managed-partition guardMT002("Tenant 'x' has no registered partition. Call AddMartenManagedTenantsAsync before appending events.") as aMartenCommandException— on both the Wolverine handler path (InvokeForTenantAsync→MartenOps.StartStream) and a directsession.Events.StartStream. Nothing is written to any partition (not the unregistered tenant, not the default, not a registered sibling).Why it originally looked silent
It was a downstream symptom of #3025. The foundational harness's
StartTallyhandler returns a singleMartenOps.StartStream, which pre-#3025 was silently dropped (noSaveChangesAsyncwithoutAutoApplyTransactions) — so the append never reached Postgres, MT002 never fired, and a later read found nothing. With #3025 fixed (6.4.4) the append executes and MT002 surfaces correctly.Test
tenant_partitioned_unregistered_tenant(MartenTests, test-only, no version bump) — asserts the unregistered-tenant append throwsMartenCommandExceptioncarryingMT002/ "has no registered partition", and that nothing leaked into the ghost / default / tenant1 partitions.Verified the test fails (no exception — the original silent symptom) when the #3025 fix is reverted, and passes with it — so it guards both the single-
IMartenOppersistence and the managed-partition guard.🤖 Generated with Claude Code