elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

Custom HTTP Endpoints in Elsa Do Not Respect TenantId in Trigger Indexing

Open dmq-kmd opened this issue 6 months ago • 1 comments

I'm opening this issue as a follow-up to a previously closed PR/discussion (#6161 ) regarding custom HttpEndpointBase activities in Elsa with multi-tenancy.

Upon investigation, I discovered that:

The TenantId is not being set in the corresponding trigger record in the database when the workflow is published.

As a result, when Elsa attempts to match the HTTP request to a trigger, the tenant context mismatch leads to no match being found — and hence the 404.

Repro Steps:

  1. Create a custom HTTP activity that extends HttpEndpointBase.
  2. Create and publish a workflow that uses CustomHttpEndpoint as the trigger under a specific tenant.
  3. Send a GET request to /api/workflows/my-path while using the same tenant context.
  4. ❌ Observe a 404 response.
  5. 🛠️ Manually update the TenantId of the trigger record in the database to match the tenant used when publishing the workflow.
  6. 🔁 Repeat the same request — now it works as expected.

Looking into the Elsa source code, the issue seems to stem from the TriggerIndexer class — particularly the CreateWorkflowTriggersAsync method. It appears the TenantId is not being correctly assigned to the WorkflowTrigger entity when the trigger is created and stored.

dmq-kmd avatar May 05 '25 06:05 dmq-kmd

I'm having the same issue when trying to create endpoints for my tenants. The TenantId is not being set in the database which means no match is found.

Emil-Hammer avatar May 20 '25 11:05 Emil-Hammer

Tested it with 3.5.0 (current tip of the develop/3.5.0 branch) and everything works with no issue. Please feel free to reopen in case you can still reproduce the issue with 3.5.0-rc3.

Thank you!

sfmskywalker avatar Aug 05 '25 20:08 sfmskywalker