Skip to content

fix(miner): exit 2, not 1, on a secret-mount failure - #6248

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
dhgoal:fix/miner-bin-exit-code
Jul 15, 2026
Merged

fix(miner): exit 2, not 1, on a secret-mount failure#6248
JSONbored merged 1 commit into
JSONbored:mainfrom
dhgoal:fix/miner-bin-exit-code

Conversation

@dhgoal

@dhgoal dhgoal commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #6162

  • bin/loopover-miner.js's loadMinerFileSecrets() catch called process.exit(1), but packages/loopover-miner/docs/unattended-scheduling.md:15-18's exit-code contract only defines 0 (success) and 2 (failure — "Alert on this"). An operator who wires alerting strictly to exit code 2, exactly as that doc instructs, silently missed a real, reachable failure: a broken GITHUB_TOKEN_FILE secret mount.
  • Now exits 2, so the documented alerting catches it.
  • Checked every other exit in the same file as the issue asks: this catch was the only hardcoded exit(1). Every other process.exit passes a subcommand's own resolved code (or 0), so there is no second miscoded startup path to fix.
  • lib/env-file-indirection.js is deliberately untouched — its throw is correct; only the CLI-boundary translation was wrong.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • The changed line is covered by an existing end-to-end test that spawns the real bin against a missing GITHUB_TOKEN_FILE. That test pinned the old status === 1, so it is updated to assert the documented 2 (plus an explicit not.toBe(1) regression guard). This is the test the issue's deliverable asks for; a second one asserting the same spawn would be redundant.
  • Ran the affected suites with vitest, all green: miner-env-file-indirection (13 tests, includes the real-bin spawn), plus miner-package-skeleton and check-miner-package (18 tests) as the other bin/package consumers.
  • No UI/MCP/worker surface is touched; leaving those suites to CI.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

The failure path is a credential-mount error: the test asserts the error names the offending var and its path, and no secret value is ever printed. This only changes the process exit code, not what is emitted.

Notes

Closes #6162

bin/loopover-miner.js's loadMinerFileSecrets catch exited 1, but
docs/unattended-scheduling.md's contract only defines 0 (success) and 2
(failure -- "Alert on this"). An operator wiring alerting strictly to exit
code 2, as that doc instructs, silently missed a broken secret mount
(a bad GITHUB_TOKEN_FILE or similar).

Checked every other exit in this file: the secret-mount catch was the only
hardcoded exit 1: the rest pass a subcommand's own resolved code or 0.
lib/env-file-indirection.js is untouched -- the throw is correct, only the
CLI-boundary translation was wrong.

The existing end-to-end test pinned status 1, so it is updated to assert the
documented 2 (it spawns the real bin against a missing GITHUB_TOKEN_FILE).

Closes JSONbored#6162
@dhgoal
dhgoal requested a review from JSONbored as a code owner July 15, 2026 23:35
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 15, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.35%. Comparing base (2af2da3) to head (d85926d).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6248   +/-   ##
=======================================
  Coverage   95.35%   95.35%           
=======================================
  Files         598      598           
  Lines       47102    47102           
  Branches    14988    14988           
=======================================
  Hits        44913    44913           
  Misses       1464     1464           
  Partials      725      725           
Flag Coverage Δ
shard-1 43.98% <ø> (-0.05%) ⬇️
shard-2 36.78% <ø> (+0.11%) ⬆️
shard-3 32.23% <ø> (+<0.01%) ⬆️
shard-4 33.96% <ø> (-0.45%) ⬇️
shard-5 31.74% <ø> (+0.12%) ⬆️
shard-6 45.22% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 15, 2026
@loopover-orb

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-15 23:55:34 UTC

2 files · 1 AI reviewer · 1 blocker · CI green · unstable

🛑 Suggested Action - Reject/Close

Review summary
This is a small, well-scoped one-line fix: `loadMinerFileSecrets()`'s catch in bin/loopover-miner.js now exits 2 instead of 1, aligning with the documented alerting contract (0=success, 2=failure) in unattended-scheduling.md. The accompanying test update correctly asserts the new exit code and explicitly checks it is not 1, directly exercising the changed line. The change is minimal, traceable to the stated issue, and the PR description confirms other exit paths were audited and left untouched.

Nits — 5 non-blocking
  • The added comment block in loopover-miner.js duplicates the PR description almost verbatim; a shorter inline note referencing the doc contract would suffice.
  • Consider also asserting `result.stderr` doesn't reference exit code 1 anywhere, though this is optional given the direct status assertion already covers the regression.
  • test/unit/miner-env-file-indirection.test.ts:162 — the `expect(result.status).not.toBe(1)` is redundant given `toBe(2)` already fully pins the value; harmless but could be dropped for brevity.
  • Pull request duplicates other open work — Check for an existing pull request or issue covering this change and coordinate or consolidate before continuing.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Why this is blocked

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ❌ Code review — 1 blocker (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6162
Related work ⚠️ Same linked issue: #6249 Another open PR references the same linked issue.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 110 registered-repo PR(s), 57 merged, 34 issue(s).
Contributor context ✅ Confirmed Gittensor contributor dhgoal; Gittensor profile; 110 PR(s), 34 issue(s).
Improvement ✅ Minor risk: low · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The catch block now exits with code 2 instead of 1, matches the documented 0/2 contract, leaves env-file-indirection.js untouched, and the diff shows an updated test asserting exit code 2 (and not 1) for a simulated missing secret file.

Review context
Contributor next steps
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (Linked issue overlaps another open PR; duplicate of another open PR). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 15, 2026
@JSONbored JSONbored reopened this Jul 15, 2026
@JSONbored
JSONbored merged commit f8aec19 into JSONbored:main Jul 15, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(miner): bin/loopover-miner.js exits 1 on a secret-mount failure, outside the documented 0/2 exit-code contract

2 participants