fix(miner): honor --json on purge arg-parse errors - #6033
Conversation
runPurge's arg-parse failure path used a bare console.error/return 2
instead of the shared reportCliFailure/argsWantJson contract, so
`purge --json` on a bad --repo value printed plain stderr text
instead of the documented {ok:false,error} envelope.
Closes JSONbored#5915
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6033 +/- ##
===========================================
+ Coverage 78.84% 95.16% +16.31%
===========================================
Files 592 592
Lines 46949 46950 +1
Branches 15003 15003
===========================================
+ Hits 37019 44680 +7661
+ Misses 7754 1512 -6242
+ Partials 2176 758 -1418
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-15 07:22:54 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 2 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
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.
|
Summary
loopover-miner purgewas already--json-aware on its success/dry-run/partial-failure outcomes, butrunPurge's top-level arg-parse failure path used a bareconsole.error(...); return 2instead of the sharedreportCliFailure/argsWantJsoncontract (cli-error.js) that the rest of the CLI suite (attempt-cli, claim-ledger-cli, discover-cli, etc.) already uses.Scripted callers that always pass
--jsonand expect{ok:false,error}regardless of outcome got plain stderr text instead on a parse failure (e.g.purge --repo bad-value --json).Behavior
--json: an arg-parse failure now prints{ "ok": false, "error": "..." }on stdout and exits 2.--json: unchanged — still prints the human-readable message to stderr and exits 2.Tests
Added a regression test in
test/unit/miner-purge-cli.test.tscovering the arg-parse error WITH--json, asserting the JSON envelope shape, that nothing is written to stderr, and the exit code. The pre-existing test right above it already covers the non---jsonstderr arm.npx vitest run test/unit/miner-purge-cli.test.ts --coverage --coverage.include='packages/loopover-miner/lib/purge-cli.js'→ 100% statements/branches/functions/lines on the changed file.Closes #5915