Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/loopover-miner/bin/loopover-miner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions test/unit/miner-env-file-indirection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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");
});
Expand Down