diff --git a/packages/loopover-miner/bin/loopover-miner.js b/packages/loopover-miner/bin/loopover-miner.js index 110f131883..cb53779d51 100755 --- a/packages/loopover-miner/bin/loopover-miner.js +++ b/packages/loopover-miner/bin/loopover-miner.js @@ -38,11 +38,13 @@ import { resolveMinerVersion } from "../lib/version.js"; // deeper in the call graph) reads plain env vars, so this single early pass is all that's needed for the whole // CLI (#5178). A broken secret mount fails the process fast and loud with a clear message, instead of an // uncaught-exception stack trace or a silent empty credential surfacing as a confusing GitHub 401 later. +// Exits 2, not 1: docs/unattended-scheduling.md's contract only defines 0 (success) and 2 (failure -- "Alert +// on this"), so an operator alerting strictly on 2 would otherwise miss a broken secret mount entirely. try { loadMinerFileSecrets(); } catch (error) { console.error(error instanceof Error ? error.message : String(error)); - process.exit(1); + process.exit(2); } // Opt-in Sentry (#6011): a complete no-op unless the operator sets LOOPOVER_MINER_SENTRY_DSN themselves. Must diff --git a/test/unit/miner-env-file-indirection.test.ts b/test/unit/miner-env-file-indirection.test.ts index 1a31c40956..5c733a75a2 100644 --- a/test/unit/miner-env-file-indirection.test.ts +++ b/test/unit/miner-env-file-indirection.test.ts @@ -149,7 +149,10 @@ describe("loadMinerFileSecrets (#5178)", () => { expect(result.stderr).not.toContain("ghp_end_to_end_value"); }); - it("fails the process fast with a clear error when GITHUB_TOKEN_FILE points at a missing file", () => { + // #6162: exit code 2, not 1 -- docs/unattended-scheduling.md's contract only defines 0 (success) and 2 + // (failure -- "Alert on this"), so an operator wiring alerting strictly to 2 must catch a broken secret + // mount like this one. + it("fails the process fast with a clear error and the documented failure exit code when GITHUB_TOKEN_FILE points at a missing file", () => { const result = spawnSync("node", [bin, "status"], { encoding: "utf8", env: { @@ -159,7 +162,8 @@ describe("loadMinerFileSecrets (#5178)", () => { }, }); - expect(result.status).toBe(1); + expect(result.status).toBe(2); + expect(result.status).not.toBe(1); expect(result.stderr).toContain("GITHUB_TOKEN_FILE"); expect(result.stderr).toContain("/definitely/does/not/exist/github_token"); });