diff --git a/apps/server/src/runs/index.ts b/apps/server/src/runs/index.ts index ec424da..c9f20fd 100644 --- a/apps/server/src/runs/index.ts +++ b/apps/server/src/runs/index.ts @@ -121,7 +121,6 @@ export async function executeRun({ config, hub, runId, request, step, rendered, if (rendered.local) exitCode = await localExec(workdir, rendered.script, env, step.attrs.sudo, timeout, output); else exitCode = await exec(client!, `cd ${shellQuote(remoteDir!)} && ${step.attrs.sudo ? "sudo -n " : ""}bash -euo pipefail -s`, scriptInput(rendered.script, env), timeout, output); streams.stdout.end(); streams.stderr.end(); - if (exitCode !== 0) hub.publish({ type: "run.error", runId, message: clean(`Script exited with code ${exitCode}`) }); if (captureTooLarge) throw new Error("Captured output exceeds 1 MiB"); if (exitCode === 0) { for (const name of rendered.artifacts) { diff --git a/apps/server/test/m2.test.ts b/apps/server/test/m2.test.ts index cd5d411..29c8a94 100644 --- a/apps/server/test/m2.test.ts +++ b/apps/server/test/m2.test.ts @@ -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: {} });