fix(multi-tenancy): stamp tenant id on bulk AddRange writes - #28
Open
ahmet-cetinkaya wants to merge 1 commit into
Open
fix(multi-tenancy): stamp tenant id on bulk AddRange writes#28ahmet-cetinkaya wants to merge 1 commit into
ahmet-cetinkaya wants to merge 1 commit into
Conversation
MultiTenancyInterceptor only handled single Add operations. An AddRangeOperation reports OperationType.AddRange with a null CurrentDocument, so bulk writes were skipped and tenant entities reached the database with a default (empty) tenant id. Unwrap AddRangeOperation.CurrentDocuments and stamp every document with the same null/default rule used for single Adds. The single-Add path and its OperationType.Add guard are unchanged, so Update/Delete/Replace are still skipped and an explicitly set tenant id is never overwritten.
ahmet-cetinkaya
marked this pull request as draft
August 2, 2026 18:42
ahmet-cetinkaya
marked this pull request as ready for review
August 12, 2026 12:50
ahmet-cetinkaya
marked this pull request as draft
August 12, 2026 12:50
ahmet-cetinkaya
marked this pull request as ready for review
August 12, 2026 13:39
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.
🚀 Context
MultiTenancyInterceptortenant id damgasını yalnız tekilAddişlemlerinde basıyordu. BirAddRangeOperation,OperationType.AddRange+CurrentDocument: nullsunduğu için interceptor toplu yazımları atlıyor; tenant belgeleri topluAddRangeyoluyla default (boş) tenant id ile veritabanına gidiyordu — bu yolda tenant isolation sessizce bozuluyordu.Gerçek consumer etkisi:
InsurUp/core'daCustomerRelationship(ITenantEntity)repository.AddRangeile yazılıyordu, yani müşteri ilişkileri tenant damgası olmadan kaydediliyordu.⚙️ Implementation Details
AddRangeOperation.CurrentDocumentsartık unwrap edilip her belge, tekilAddile aynınull || defaultkuralıyla damgalanıyor. TekilAddyolu ve onunOperationType.Addguard'ı değişmedi; dolayısıyla:Update/Delete/Replacehâlâ atlanıyor (tenant'ın değişmemesi gereken yazımlarda yeniden damgalanmıyor).Davranış değişimi: toplu yazımlar artık tekil yazımların zaten aldığı damgayı alıyor (eskiden hiç almıyordu). Yalnızca id'si set edilmemiş belgeler etkilenir; tenant'ı zaten veren consumer'lar etkilenmez.
🧪 Validation
Bu repoda test projesi yok; doğrulama consumer-side:
InsurUp/coreTenantIsolationTests— gerçek MongoDB replica set üzerinde red→green koşusu, topluAddRangebelgelerininAgentId = 00000000…(default) değerinden acting tenant id'sine geçtiğini kanıtlar. Core şu an bu değişikliğin consumer-side muadili olan geçiciTenantEntityInterceptorworkaround'unu taşıyor; bu fix yayınlanıp consume edilince silinecek.dotnet build -c Release -t:Rebuild /warnaserror→ 0 warning, 0 error (net8.0,net9.0).Versioning: csproj'da
<Version>yok; release'ler tag-driven (sonv0.5.5). Merge sonrası bir maintainer tag'i (örn.v0.5.6) fix'i yayınlar.🔗 Related
TenantEntityInterceptorworkaround'unu içeriyor ve bu upstream takibini belgeliyor; workaround, bu fix yayınlanıp core'dakiMongoFlowpackage reference yükseltilince kaldırılacak.