Skip to content

Commit 73fb413

Browse files
committed
Added metadata to ServiceValidationError in some critical places
1 parent c128819 commit 73fb413

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

internal-packages/run-engine/src/engine/systems/checkpointSystem.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,25 @@ export class CheckpointSystem {
270270
const snapshot = await getLatestExecutionSnapshot(prisma, runId);
271271

272272
if (snapshot.id !== snapshotId) {
273-
throw new ServiceValidationError("Snapshot ID doesn't match the latest snapshot", 400);
273+
throw new ServiceValidationError(
274+
"Snapshot ID doesn't match the latest snapshot in continueRunExecution",
275+
400,
276+
{
277+
snapshotId,
278+
latestSnapshotId: snapshot.id,
279+
}
280+
);
274281
}
275282

276283
if (!isPendingExecuting(snapshot.executionStatus)) {
277-
throw new ServiceValidationError("Snapshot is not in a valid state to continue", 400);
284+
throw new ServiceValidationError(
285+
"Snapshot is not in a valid state to continue in continueRunExecution",
286+
400,
287+
{
288+
snapshotId,
289+
snapshotStatus: snapshot.executionStatus,
290+
}
291+
);
278292
}
279293

280294
// Get the run and update the status

internal-packages/run-engine/src/engine/systems/runAttemptSystem.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,16 @@ export class RunAttemptSystem {
318318
//if there is a big delay between the snapshot and the attempt, the snapshot might have changed
319319
//we just want to log because elsewhere it should have been put back into a state where it can be attempted
320320
this.$.logger.warn(
321-
"RunEngine.createRunAttempt(): snapshot has changed since the attempt was created, ignoring."
321+
"RunEngine.createRunAttempt(): snapshot has changed since the attempt was created, ignoring.",
322+
{
323+
snapshotId,
324+
latestSnapshotId: latestSnapshot.id,
325+
}
322326
);
323-
throw new ServiceValidationError("Snapshot changed", 409);
327+
throw new ServiceValidationError("Snapshot changed inside startRunAttempt", 409, {
328+
snapshotId,
329+
latestSnapshotId: latestSnapshot.id,
330+
});
324331
}
325332

326333
const taskRun = await prisma.taskRun.findFirst({

0 commit comments

Comments
 (0)