Fix cross-tenant cache collision in CachingWorkflowDefinitionService#7318
Merged
sfmskywalker merged 2 commits intorelease/3.6.0from Feb 23, 2026
Merged
Fix cross-tenant cache collision in CachingWorkflowDefinitionService#7318sfmskywalker merged 2 commits intorelease/3.6.0from
sfmskywalker merged 2 commits intorelease/3.6.0from
Conversation
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix caching workflow definition service for tenant isolation
Fix cross-tenant cache collision in CachingWorkflowDefinitionService
Feb 23, 2026
sfmskywalker
approved these changes
Feb 23, 2026
Contributor
Greptile SummaryAdds tenant-scoped cache key prefixes to
The fix ensures that Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionCacheManager.cs | Added tenant isolation to cache keys by injecting ITenantAccessor and prefixing all cache keys with {tenantId}: when a tenant is active |
Sequence Diagram
sequenceDiagram
participant Client as Client Request
participant Service as CachingWorkflowDefinitionService
participant CacheMgr as WorkflowDefinitionCacheManager
participant TenantAccessor as ITenantAccessor
participant Cache as ICacheManager
Client->>Service: FindWorkflowGraphAsync(definitionId, versionOptions)
Service->>CacheMgr: CreateWorkflowVersionCacheKey(definitionId, versionOptions)
CacheMgr->>TenantAccessor: Get TenantId
TenantAccessor-->>CacheMgr: Returns "tenant-A"
CacheMgr->>CacheMgr: TenantPrefix() → "tenant-A:"
CacheMgr-->>Service: Returns "tenant-A:Workflow:definitionId:versionOptions"
Service->>Cache: GetOrCreateAsync(key)
alt Cache Hit
Cache-->>Service: Return cached WorkflowGraph for tenant-A
else Cache Miss
Service->>Service: decoratedService.FindWorkflowGraphAsync()
Service->>Cache: Store with tenant-scoped key
end
Service-->>Client: Return tenant-isolated WorkflowGraph
Last reviewed commit: 7d02d3d
This was referenced Mar 5, 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.
In multi-tenant deployments,
WorkflowDefinitionCacheManagergenerated cache keys with no tenant scope, causingCachingWorkflowDefinitionServiceto serve cached workflow definitions from one tenant to another when workflows share the same name or definition ID.Changes
WorkflowDefinitionCacheManager: InjectedITenantAccessorand added aTenantPrefix()helper that prepends"{tenantId}:"to every generated cache key. When no tenant is active (single-tenant), the prefix is empty — no behavioral change.This mirrors the isolation pattern already applied in
CachingWorkflowDefinitionStore:All
Create*CacheKeymethods — including definition version keys, filter-based keys, and change token keys — are now tenant-scoped.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.