From 9ad886eedc4221f10001c188e1ddddd9e16c434b Mon Sep 17 00:00:00 2001 From: real-venus Date: Wed, 15 Jul 2026 16:34:57 -0700 Subject: [PATCH] fix(miner): exit 2 (not 1) on a secret-mount failure to match the documented 0/2 exit-code contract --- packages/loopover-miner/bin/loopover-miner.js | 5 ++++- test/unit/miner-env-file-indirection.test.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/loopover-miner/bin/loopover-miner.js b/packages/loopover-miner/bin/loopover-miner.js index 110f131883..7d56b4f6c6 100755 --- a/packages/loopover-miner/bin/loopover-miner.js +++ b/packages/loopover-miner/bin/loopover-miner.js @@ -42,7 +42,10 @@ try { loadMinerFileSecrets(); } catch (error) { console.error(error instanceof Error ? error.message : String(error)); - process.exit(1); + // Exit 2, not 1: a broken secret mount is a real startup failure, and docs/unattended-scheduling.md's + // exit-code contract is 0 (success) / 2 (failure — "Alert on this"). Exiting 1 here would slip past an + // operator whose alerting keys strictly on exit code 2 (#6162). + 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..dba773d1cd 100644 --- a/test/unit/miner-env-file-indirection.test.ts +++ b/test/unit/miner-env-file-indirection.test.ts @@ -149,7 +149,7 @@ 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", () => { + it("fails the process fast with the documented failure exit code (2) when GITHUB_TOKEN_FILE points at a missing file (#6162)", () => { const result = spawnSync("node", [bin, "status"], { encoding: "utf8", env: { @@ -159,7 +159,8 @@ describe("loadMinerFileSecrets (#5178)", () => { }, }); - expect(result.status).toBe(1); + // Exit 2 (not 1) so it matches docs/unattended-scheduling.md's 0/2 contract and an operator's exit-code-2 alerting. + expect(result.status).toBe(2); expect(result.stderr).toContain("GITHUB_TOKEN_FILE"); expect(result.stderr).toContain("/definitely/does/not/exist/github_token"); });