fix(server): report failing scripts via run.finished only (#4)

A non-zero exit is a normal result (a failed check shows as a cross), not an execution error; publishing run.error showed an error banner for every failed check.
This commit is contained in:
Florian Schmidt
2026-11-16 00:21:17 +01:00
parent d10b2114df
commit b50d49b790
2 changed files with 9 additions and 1 deletions
+9
View File
@@ -119,6 +119,15 @@ describe("SSH with a deterministic in-process server", () => {
expect(JSON.parse(audit).script).toBe(r.script);
expect(audit + JSON.stringify(events)).not.toContain("secret'word");
});
it("reports a failing script only through run.finished, not as a run.error", async () => {
// A failing check is a normal result (❌), not a transport/execution error.
const { config, host, fp } = await sshFixture();
const hub = new EventsHub(); const events: ServerEvent[] = []; hub.subscribe(e => events.push(e));
const r = rendered(); r.script = "FAIL";
await executeRun({ config, hub, runId: randomUUID(), request: { ...request(), acceptHostKey: fp }, step: step(), rendered: r, host, env: {} });
expect(events.at(-1)).toMatchObject({ type: "run.finished", exitCode: 7 });
expect(events.some(e => e.type === "run.error")).toBe(false);
});
it("emits TOFU events and a failed audited result", async () => {
const { config, host, fp } = await sshFixture(); const hub = new EventsHub(); const events: ServerEvent[] = []; hub.subscribe(e => events.push(e));
await executeRun({ config, hub, runId: randomUUID(), request: request(), step: step(), rendered: rendered(), host, env: {} });