You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report: Conflict with AddFastEndpoints in Elsa's Module Configuration
Description
Elsa's API feature automatically calls AddFastEndpoints within a nested extension method (AddFastEndpointsFromModule), causing conflicts for applications that also use FastEndpoints independently. Since FastEndpoints should be registered only once, the current design leads to bad endpoint configuration issues and prevents developers from having full control over their FastEndpoints setup. Furthermore, UseWorkflowsApi calls app.UseFastEndpoints without limiting this configuration to Elsa's own assemblies. This causes endpoints to be mapped multiple times with different configurations.
Steps to Reproduce
Create an application that uses Elsa’s workflow API (Elsa.Workflows.Api) and FastEndpoints.
Notice that Elsa’s internal call to AddFastEndpoints occurs within ModuleExtensions.AddFastEndpointsFromModule().
Notice that Elsa’s internal call to UseFastEndpoints or within WebApplicationExtensions.UseWorkflowsApi() is not limited to elsa's own endpoints, same goes for MapWorkflowsApi.
Attempt to register additional FastEndpoints in Program.cs with a different configuration that conflicts with Elsa (i.e. c.Endpoints.ShortNames = true;) using UseFastEndpoints or MapFastEndpoints after the elsa configuration.
Run the application and encounter conflicts due to conflicting endpoint registrations.
Reproduction Rate: Always if using mentioned configuration.
Expected Behavior
Leave the configuration of FastEndpoints up to the programmer in the startup.cs
Mapping of endpoints is limited to Elsa's own endpoints.
Actual Behavior
Elsa takes over FE configuration itself.
Mapping endpoints is not limited to Elsa's own endpoints.
Troubleshooting Attempts
The following works for my use case. Note: this is my own specific code, some of this may not be relevant.
I have made a copy of the WorkflowsApiFeature excluding the call to add FE.
I made a static container gathering all the necessary assemblies.
I have added those assemblies to the AddFastEndpoint assemblies configuration.
Limited the mapping to Elsa('s own name space).
endpoints.MapFastEndpoints(config =>{config.Endpoints.RoutePrefix="elsa/api";config.Endpoints.ShortNames=false;config.Endpoints.Configurator= ep =>ep.Tags("elsa");config.Endpoints.Filter=(ep)=>ep.EndpointType.Namespace?.StartsWith("Elsa")==true;config.Serializer.RequestDeserializer=ElsaSerializers.DeserializeRequestAsync;config.Serializer.ResponseSerializer=ElsaSerializers.SerializeRequestAsync;});
Added Elsa swagger docs by using the tag I added in the snippet above:
services.SwaggerDocument(o =>{// Use elsa tag to filter out endpoints that are not elsa relatedo.EndpointFilter= ep =>ep.EndpointTags?.Contains("elsa")==true;// Check if has ElsaEndpoint wrapped classo.DocumentSettings= s =>{s.DocumentName="elsa";s.Title=$"ORG (Elsa)";s.Version="v1.0";};});
Additional Context
I am not sure what the perfect solution would be here.
This convention is used in other places as well (SignalR hub for example).
I get that this is difficult because it's a though line between giving the user too much control and potentially breaking Elsa configuration.
The text was updated successfully, but these errors were encountered:
Bug Report: Conflict with
AddFastEndpoints
in Elsa's Module ConfigurationDescription
Elsa's API feature automatically calls
AddFastEndpoints
within a nested extension method (AddFastEndpointsFromModule
), causing conflicts for applications that also use FastEndpoints independently. Since FastEndpoints should be registered only once, the current design leads to bad endpoint configuration issues and prevents developers from having full control over their FastEndpoints setup. Furthermore, UseWorkflowsApi calls app.UseFastEndpoints without limiting this configuration to Elsa's own assemblies. This causes endpoints to be mapped multiple times with different configurations.Steps to Reproduce
Elsa.Workflows.Api
) and FastEndpoints.AddFastEndpoints
occurs withinModuleExtensions.AddFastEndpointsFromModule()
.UseFastEndpoints
or withinWebApplicationExtensions.UseWorkflowsApi()
is not limited to elsa's own endpoints, same goes forMapWorkflowsApi
.Program.cs
with a different configuration that conflicts with Elsa (i.e.c.Endpoints.ShortNames = true;
) usingUseFastEndpoints
orMapFastEndpoints
after the elsa configuration.Reproduction Rate: Always if using mentioned configuration.
Expected Behavior
Actual Behavior
Troubleshooting Attempts
The following works for my use case. Note: this is my own specific code, some of this may not be relevant.
WorkflowsApiFeature
excluding the call to add FE.Additional Context
I am not sure what the perfect solution would be here.
This convention is used in other places as well (SignalR hub for example).
I get that this is difficult because it's a though line between giving the user too much control and potentially breaking Elsa configuration.
The text was updated successfully, but these errors were encountered: