-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description
When an activity is waiting for other activities to completed. It then uses the outcomes of those other activities to do some work and throw possibly an exception, the resulting Incident contains the activity Id of one of the scheduled activities.
Steps to Reproduce
Take for example the following activity:
internal class ConstrainActivity : Activity<float>
{
private float? _valueValue, _lowValue, _highValue;
public IActivity Value { get; }
public IActivity Low { get; }
public IActivity High { get; }
public ConstrainActivity(string activityId, IActivity value, IActivity low, IActivity high)
{
this.Id = activityId;
this.Value = value;
this.Low = low;
this.High = high;
}
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
this._valueValue = null;
this._lowValue = null;
this._highValue = null;
await context.ScheduleActivities([this.Value, this.Low, this.High], this.OnChildCompleted);
}
private async ValueTask OnChildCompleted(ActivityCompletedContext context)
{
object? result = context.WorkflowExecutionContext.GetLastActivityResult();
if (result is float value)
{
if (context.ChildContext.Activity == this.Value)
{
this._valueValue = value;
}
else if (context.ChildContext.Activity == this.Low)
{
this._lowValue = value;
}
else if (context.ChildContext.Activity == this.High)
{
this._highValue = value;
}
}
if (this._valueValue != null && this._lowValue != null && this._highValue != null)
{
if (this._lowValue >= this._highValue)
{
throw new ActivityException(this.Id, "Left value must be smaller than right value");
}
float number;
if (this._valueValue < this._lowValue)
{
number = this._lowValue.Value;
}
else if (this._valueValue > this._highValue)
{
number = this._highValue.Value;
}
else
{
number = this._valueValue.Value;
}
context.TargetContext.SetResult(number);
await context.CompleteActivityAsync();
}
}
}If the result of the Low activity > the result of the High activity, an error is thrown. However, the Activity Id in the incident is that of the High activity instead of the current ConstrainActivity.
Expected Behavior
The Id of the activity to be that of the ConstrainActivity in the incident.
I would also expect the Incident to actually contain the exception, not just the message and stacktrace. If Incidents contain the actual exception we can put additional information in there which is currently lost.
Actual Behavior
The Activity Id in the incident is that of the High activity instead of the current ConstrainActivity.
Screenshots
"this.Id" is de Id of the activity throwing the exception (of the class specified above)
"state" in the following screenshot is a WorkflowState instance provided via "INotificationHandler"

Environment
- Elsa Package Version: 3.3.5
- Operating System: Windows 11
edit: Edited to contain the actual description and not just the template text :)
edit2: clarified de screenshot a bit more.