Proto.Actor tenant header is never propagated: MessageEnvelope.WithHeader result is discarded
TenantScopeMiddleware.PropagateTenant (src/extensions/actors/Elsa.Actors.ProtoActor/Middleware/TenantScopeMiddleware.cs, imported from Extensions) calls envelope.WithHeader(HeaderNames.TenantId, tenant.Id) and discards the result. In Proto.Actor 1.8.0, MessageEnvelope.WithHeader returns a new envelope ("New envelope" in its XML docs), so the original envelope goes to next without the header.
As a result, a message sent from a tenant context never carries TenantId. ReadTenant on the receiving actor never creates a tenant scope, so the actor runs in whatever service provider it already had.
Fix: pass envelope.WithHeader(...) to next. This turns on tenant scoping in actor receivers, which is a runtime behaviour change, so it needs:
- a test that a tenant-context send reaches the receiver with the header and a tenant-scoped provider;
- a check of the workflow runtime paths that rely on it (
ProtoActorWorkflowClient, persisted resume).
Found while making the middleware tolerate hosts without multitenancy during the history import (#8286). That change deliberately kept the existing propagation behaviour.
Source: elsa-workflows/elsa-core