From 643ffa3328c8cf851aa61180248a2ce080dc6a2c Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 5 Jul 2021 13:12:36 +0200 Subject: [PATCH 1/2] Remove invalid namespace --- src/samples/server/Elsa.Samples.Server.Host/Startup.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/samples/server/Elsa.Samples.Server.Host/Startup.cs b/src/samples/server/Elsa.Samples.Server.Host/Startup.cs index 4178a5ff0..0aac4f73a 100644 --- a/src/samples/server/Elsa.Samples.Server.Host/Startup.cs +++ b/src/samples/server/Elsa.Samples.Server.Host/Startup.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Elsa.Samples.Server.Host.Activities; using Elsa.Server.Hangfire.Extensions; using Hangfire; using Microsoft.AspNetCore.Builder; From 6f94d0a93fb9ee0383c5690c77c8adc226a469ce Mon Sep 17 00:00:00 2001 From: Vlad Crisan Date: Tue, 6 Jul 2021 09:52:30 +0300 Subject: [PATCH 2/2] http endpoint respond with 500 for faulted workflow having a fault in a workflow started through http endpoint returns 500 only in case the response has not alerady been started --- .../Middleware/HttpEndpointMiddleware.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs b/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs index b4a33bf7a..f32b1294f 100644 --- a/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs +++ b/src/activities/Elsa.Activities.Http/Middleware/HttpEndpointMiddleware.cs @@ -115,6 +115,28 @@ namespace Elsa.Activities.Http.Middleware else { await workflowLaunchpad.ExecutePendingWorkflowAsync(pendingWorkflow, inputModel, cancellationToken); + pendingWorkflowInstance = await workflowInstanceStore.FindByIdAsync(pendingWorkflow.WorkflowInstanceId); + + if (pendingWorkflowInstance is not null + && pendingWorkflowInstance.WorkflowStatus == Elsa.Models.WorkflowStatus.Faulted + && !httpContext.Response.HasStarted) + { + httpContext.Response.ContentType = "application/json"; + httpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + + var faultedResponse = JsonConvert.SerializeObject(new + { + errorMessage = $"Workflow faulted at {pendingWorkflowInstance.FaultedAt!} with error: {pendingWorkflowInstance.Fault!.Message}", + workflow = new + { + name = pendingWorkflowInstance.Name, + version = pendingWorkflowInstance.Version, + instanceId = pendingWorkflowInstance.Id + } + }); + + await httpContext.Response.WriteAsync(faultedResponse, cancellationToken); + } } } }