Store history when iterator reset the step info (#14684)

- before reseting the step, enrich info with previous result
- reset only when a step is executed more than once. This will avoid to
store the initial `NOT_STARTED` status of the step
This commit is contained in:
Thomas Trompette
2025-09-24 15:28:50 +02:00
committed by GitHub
parent f5c5ee5645
commit 3b1657b6fa
2 changed files with 22 additions and 1 deletions
@@ -105,7 +105,7 @@ export class IteratorWorkflowAction implements WorkflowActionInterface {
hasProcessedAllItems,
};
if (!hasProcessedAllItems) {
if (!hasProcessedAllItems && currentItemIndex > 0) {
await this.resetStepsInLoop({
iteratorStepId,
initialLoopStepIds,
@@ -140,6 +140,14 @@ export class IteratorWorkflowAction implements WorkflowActionInterface {
steps,
});
const workflowRunToUpdate =
await this.workflowRunWorkspaceService.getWorkflowRunOrFail({
workflowRunId,
workspaceId,
});
const stepInfos = workflowRunToUpdate.state.stepInfos;
await this.workflowRunWorkspaceService.updateWorkflowRunStepInfos({
stepInfos: stepIdsToReset.reduce(
(acc, stepId) => {
@@ -147,6 +155,14 @@ export class IteratorWorkflowAction implements WorkflowActionInterface {
status: StepStatus.NOT_STARTED,
result: undefined,
error: undefined,
history: [
...(stepInfos[stepId]?.history ?? []),
{
result: stepInfos[stepId]?.result,
error: stepInfos[stepId]?.error,
status: stepInfos[stepId]?.status,
},
],
};
return acc;