Skip to content

Commit 5c19ae5

Browse files
committed
WIP fix for ResumeAttemptService selecting the wrong attempt (which has no error or output)
1 parent a50b93f commit 5c19ae5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/webapp/app/v3/services/resumeAttempt.server.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export class ResumeAttemptService extends BaseService {
2727
take: 1,
2828
select: {
2929
id: true,
30+
number: true,
31+
status: true,
3032
},
3133
} satisfies Prisma.TaskRunInclude["attempts"];
3234

@@ -130,7 +132,20 @@ export class ResumeAttemptService extends BaseService {
130132
return;
131133
}
132134

133-
completedAttemptIds = dependentBatchItems.map((item) => item.taskRun.attempts[0]?.id);
135+
//find the best attempt for each batch item
136+
//it should be the most recent one in a final state
137+
const finalAttempts = dependentBatchItems.map((item) => {
138+
return item.taskRun.attempts
139+
.filter((a) => FINAL_ATTEMPT_STATUSES.includes(a.status))
140+
.sort((a, b) => b.number - a.number)[0];
141+
});
142+
143+
completedAttemptIds = finalAttempts.map((a) => a.id);
144+
145+
if (completedAttemptIds.length !== dependentBatchItems.length) {
146+
this._logger.error("[ResumeAttemptService] not all batch items have attempts");
147+
return;
148+
}
134149
} else {
135150
this._logger.error("No batch dependency");
136151
return;

0 commit comments

Comments
 (0)