Skip to content

Conversation

@Sverre-W
Copy link
Contributor

@Sverre-W Sverre-W commented Nov 7, 2025

This PR fixes #7034. By passing in the tenant headers when executing Cancel to a suspended workflow with the default cancellation dispatcher.


This change is Reviewable

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds tenant header support to BackgroundWorkflowCancellationDispatcher to fix issue #7034, ensuring that tenant context is properly propagated when canceling suspended workflows using the default cancellation dispatcher.

Key Changes:

  • Added ITenantAccessor dependency injection to BackgroundWorkflowCancellationDispatcher
  • Added imports for tenant-related namespaces (Elsa.Common.Multitenancy and Elsa.Tenants.Mediator)
  • Implemented CreateHeaders() method to generate tenant headers from the current tenant context

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@Sverre-W
Copy link
Contributor Author

Sverre-W commented Jan 9, 2026

@sfmskywalker would it be possible to still sneak this in 3.6 😄?

@sfmskywalker
Copy link
Member

Yes! Please try targeting the release/3.6.0 branch, hopefully it’s not too divergent :)

@Sverre-W Sverre-W changed the base branch from main to release/3.6.0 January 12, 2026 03:10
@dmq-kmd
Copy link

dmq-kmd commented Jan 16, 2026

@Sverre-W @sfmskywalker We’re seeing the same issue in a multi-tenant setup, so this would be a much-appreciated fix 😄

@sfmskywalker sfmskywalker merged commit bc70bef into elsa-workflows:release/3.6.0 Jan 16, 2026
11 of 13 checks passed
sfmskywalker added a commit that referenced this pull request Jan 19, 2026
* Add tenant headers support to BackgroundWorkflowCancellationDispatcher (#7040)

* Add tenant headers support to BackgroundWorkflowCancellationDispatcher

* Fix 'CreateHeaders' call

* Fix memory leak: Dispose IronCompressResult in Zstd codec (#7193)

* Initial plan

* Fix memory leak: Dispose IronCompressResult in Zstd codec and add tests

Co-authored-by: sfmskywalker <[email protected]>

* Refactor tests to be more DRY using Theory and InlineData

Co-authored-by: sfmskywalker <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>

* Introduce `IMaterializerRegistry` to manage workflow materializers and ensure availability checks.

* Extend `IWorkflowDefinitionService` and `CachingWorkflowDefinitionService` with workflow graph lookup methods (`TryFindWorkflowGraphAsync`). Refactor caching and materialization logic for consistency.

* Refactor caching interface and implementation: add `FindOrCreateAsync`, update `GetOrCreateAsync` to ensure non-null results, and improve exception handling.

* Refactor `GetWorkflowGraphAsync` to use `TryFindWorkflowGraphAsync` and improve exception handling for missing workflow definitions and materializers.

* Refactor caching logic to replace `GetOrCreateAsync` with `FindOrCreateAsync` for improved clarity and consistency.

* Update workflow model, add event, and mark exception obsolete

Updated `TimestampFilter.Column` to use a `null!` default value for clarity. Added `Event1` in the `hello-world.elsa` workflow and removed an unused folder entry from the project. Marked `WorkflowGraphNotFoundException` as obsolete with guidance to use `WorkflowDefinitionNotFoundException` instead.

* Add new workflow files and exception classes for Elsa

Introduced a workflow definition file "eventing.json" and new exception classes (`WorkflowDefinitionNotFoundException` and `WorkflowMaterializerNotFoundException`) to enhance handling of workflow-related errors. Also added a `WorkflowGraphFindResult` model for better workflow graph management. These changes improve the structure and functionality of the workflow system.

* Add unit tests for `CachingWorkflowDefinitionService` and related helpers

Introduce comprehensive unit tests to validate caching logic, workflow graph/materialization behavior, and cache key generation in `CachingWorkflowDefinitionService`. Add `WorkflowDefinitionServiceTests` and helper methods for streamlined test setup.

* Enable `UseElsaScriptBlobStorage` in workflow server configuration

* Refactor `BackgroundWorkflowCancellationDispatcher` to simplify object initialization and clean up XML documentation comments

* Address PR #7195 review feedback: optimize caching, improve exceptions, add test coverage (#7196)

* Initial plan

* Apply PR review feedback: Fix exceptions, optimize caching, improve error handling

Co-authored-by: sfmskywalker <[email protected]>

* Add unit tests for MaterializerRegistry and LocalWorkflowClient exception handling

Co-authored-by: sfmskywalker <[email protected]>

* Add unit tests for BackgroundWorkflowCancellationDispatcher tenant headers

Co-authored-by: sfmskywalker <[email protected]>

* Refactor `WorkflowMaterializerNotFoundException` to improve structure and usability, update related references, and simplify object initialization in test cases.

* Update `WorkflowDefinitionServiceTests` to use `WorkflowMaterializerNotFoundException` in place of `InvalidOperationException` for materializer not found scenario

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>
Co-authored-by: Sipke Schoorstra <[email protected]>

* Potential fix for pull request finding 'Inefficient use of ContainsKey'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Refactor tests and services: simplify object initialization, use target-typed `new()` syntax, and replace `CancellationToken` with `CancellationToken.None` where applicable.

* Refactor tests in `BackgroundWorkflowCancellationDispatcherTests`: improve tenant initialization and optimize header checks by replacing `TryGetValue` with `ContainsKey`.

---------

Co-authored-by: Sverre Winkelmans <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
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.

Workflow Cancellation not working in Elsa Studio

3 participants