From cbbd317fb59647a3dfd97c685b060d07eb42e39a Mon Sep 17 00:00:00 2001 From: Abel Yagubyan Date: Wed, 21 Oct 2026 17:53:22 -0400 Subject: [PATCH] fix(process): index late scenario events in validation issues (#6160) Co-authored-by: Abelo9996 --- src/domain/process/processScenario.test.ts | 27 ++++++++++++++++++++++ src/domain/process/processScenario.ts | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/domain/process/processScenario.test.ts b/src/domain/process/processScenario.test.ts index 529fcc2d9a..450d873673 100644 --- a/src/domain/process/processScenario.test.ts +++ b/src/domain/process/processScenario.test.ts @@ -210,3 +210,30 @@ it("applies the selected scrollback budget to every scheduled resize", () => { }).success, ).toBe(true); }); + +it("identifies each event scheduled after the scenario timeout", () => { + const parsed = processScenarioSchema.safeParse({ + executable: "/bin/true", + timeout_ms: 1_000, + events: [ + { type: "input", at_ms: 1_000, data: "a" }, + { type: "input", at_ms: 1_500, data: "b" }, + { type: "signal", at_ms: 2_000, signal: "SIGINT" }, + ], + }); + + expect(parsed.success).toBe(false); + if (parsed.success) throw new Error("expected late event rejection"); + expect(parsed.error.issues).toEqual([ + expect.objectContaining({ + code: "custom", + path: ["events", 1], + message: "event at 1500 ms occurs after the 1000 ms scenario timeout", + }), + expect.objectContaining({ + code: "custom", + path: ["events", 2], + message: "event at 2000 ms occurs after the 1000 ms scenario timeout", + }), + ]); +}); diff --git a/src/domain/process/processScenario.ts b/src/domain/process/processScenario.ts index bfaab26727..ba1376524e 100644 --- a/src/domain/process/processScenario.ts +++ b/src/domain/process/processScenario.ts @@ -298,8 +298,8 @@ export const processScenarioSchema = z if (event.at_ms > scenario.timeout_ms) { context.addIssue({ code: "custom", - message: "event occurs after the scenario timeout", - path: ["events"], + message: `event at ${String(event.at_ms)} ms occurs after the ${String(scenario.timeout_ms)} ms scenario timeout`, + path: ["events", index], }); } }