diff --git a/src/Rebus.Operations/Rebus.Operations.Core/Workflow/FailedOperationHandler.cs b/src/Rebus.Operations/Rebus.Operations.Core/Workflow/FailedOperationHandler.cs index 004b069..bd59d3b 100644 --- a/src/Rebus.Operations/Rebus.Operations.Core/Workflow/FailedOperationHandler.cs +++ b/src/Rebus.Operations/Rebus.Operations.Core/Workflow/FailedOperationHandler.cs @@ -33,10 +33,16 @@ public async Task Handle(IFailed failedMessage) failedMessage.Message.TaskId, failedMessage.ErrorDescription ); + var failedTaskId = failedMessage.Message.TaskId; + + // assign errors on status events to initiating task + if(failedMessage.Message is IOperationTaskStatusEvent statusEvent) + failedTaskId = statusEvent.InitiatingTaskId; + await _operationMessaging.DispatchTaskStatusEventAsync( OperationTaskStatusEvent.Failed( failedMessage.Message.OperationId, failedMessage.Message.InitiatingTaskId, - failedMessage.Message.TaskId, new ErrorData() { ErrorMessage = failedMessage.ErrorDescription }, + failedTaskId, new ErrorData() { ErrorMessage = failedMessage.ErrorDescription }, _workflowOptions.JsonSerializerOptions)); diff --git a/src/Rebus.Operations/Rebus.Operations.Primitives/Events/OperationTaskStatusEventBase.cs b/src/Rebus.Operations/Rebus.Operations.Primitives/Events/OperationTaskStatusEventBase.cs index 9e8a3b4..10f16ee 100644 --- a/src/Rebus.Operations/Rebus.Operations.Primitives/Events/OperationTaskStatusEventBase.cs +++ b/src/Rebus.Operations/Rebus.Operations.Primitives/Events/OperationTaskStatusEventBase.cs @@ -4,7 +4,7 @@ namespace Dbosoft.Rebus.Operations.Events; #nullable enable -public class OperationTaskStatusEventBase : IOperationTaskMessage +public class OperationTaskStatusEventBase : IOperationTaskStatusEvent { public OperationTaskStatusEventBase() {} diff --git a/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskMessage.cs b/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskMessage.cs index e7af6ac..8d2e24c 100644 --- a/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskMessage.cs +++ b/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskMessage.cs @@ -13,5 +13,4 @@ public interface IOperationTaskMessage Guid TaskId { get; } } - } \ No newline at end of file diff --git a/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskStatusEvent.cs b/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskStatusEvent.cs new file mode 100644 index 0000000..1f67a66 --- /dev/null +++ b/src/Rebus.Operations/Rebus.Operations.Primitives/IOperationTaskStatusEvent.cs @@ -0,0 +1,6 @@ +namespace Dbosoft.Rebus.Operations; + +public interface IOperationTaskStatusEvent : IOperationTaskMessage +{ + +} \ No newline at end of file