Skip to content

Pin unregistered-tenant MT002 behavior under UseTenantPartitionedEvents (GH-3021)#3031

Merged
jeremydmiller merged 1 commit into
mainfrom
feat-3021-unregistered-tenant-investigation
Jun 4, 2026
Merged

Pin unregistered-tenant MT002 behavior under UseTenantPartitionedEvents (GH-3021)#3031
jeremydmiller merged 1 commit into
mainfrom
feat-3021-unregistered-tenant-investigation

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Advances #3021 Phase 1 — resolves the flagged investigation item:

Investigate: an append for a never-registered tenant via InvokeForTenantAsync did not surface MT002 in the foundational harness (possible silent misroute) — confirm and pin.

Finding: not a silent misroute

An append for a tenant that was never registered via AddMartenManagedTenantsAsync raises Marten's managed-partition guard MT002 ("Tenant 'x' has no registered partition. Call AddMartenManagedTenantsAsync before appending events.") as a MartenCommandException — on both the Wolverine handler path (InvokeForTenantAsyncMartenOps.StartStream) and a direct session.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 StartTally handler returns a single MartenOps.StartStream, which pre-#3025 was silently dropped (no SaveChangesAsync without AutoApplyTransactions) — 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 throws MartenCommandException carrying MT002 / "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-IMartenOp persistence and the managed-partition guard.

🤖 Generated with Claude Code

…-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>
@jeremydmiller jeremydmiller merged commit 6040eae into main Jun 4, 2026
23 of 24 checks passed
This was referenced Jun 8, 2026
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.

1 participant