Context
This repo has an established JSON error-contract convention for CLIs (packages/loopover-miner/lib/cli-error.js's reportCliFailure): when --json is set, a failure emits a parseable { ok: false, error } object on stdout instead of plain text on stderr. Two other commands in this exact family were just fixed for this same bug (#5914/#6034, #6033).
packages/loopover-miner/lib/discover-cli.js's runDiscover has the same bug in its --dry-run branch. The non-dry-run failure path correctly calls reportCliFailure(parsed.json, ...) (a few lines below, in the main flow), but the --dry-run branch's own catch block does a raw, unconditional:
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
return 2;
}
So loopover-miner discover --dry-run --json on a fetch/rank failure prints plain text to stderr instead of parseable JSON to stdout — breaking any --json-consuming caller (CI, the MCP wrapper, a script) exactly when it most needs a structured error. test/unit/miner-discover-cli.test.ts's two "--dry-run reports fan-out failures" tests only exercise the non---json case, so this combination is untested today.
Requirements
- The
--dry-run branch's catch block in runDiscover (packages/loopover-miner/lib/discover-cli.js) must call reportCliFailure(parsed.json, describeCliError(error)) (or the equivalent already used by this file's non-dry-run path) instead of the raw console.error/return 2.
- Behavior for the non-
--json case must be unchanged (plain-text stderr output stays plain text).
- Do not touch any other command's
--dry-run handling in this PR — this issue is scoped to discover-cli.js only.
Deliverables
Test Coverage Requirements
99%+ patch coverage (branch-counted) on the changed branch in discover-cli.js.
Expected Outcome
loopover-miner discover --dry-run --json on any fetch/rank failure prints valid, parseable {ok:false,error} JSON on stdout — matching every other command's --json error contract in this package.
Links & Resources
Context
This repo has an established JSON error-contract convention for CLIs (
packages/loopover-miner/lib/cli-error.js'sreportCliFailure): when--jsonis set, a failure emits a parseable{ ok: false, error }object on stdout instead of plain text on stderr. Two other commands in this exact family were just fixed for this same bug (#5914/#6034,#6033).packages/loopover-miner/lib/discover-cli.js'srunDiscoverhas the same bug in its--dry-runbranch. The non-dry-run failure path correctly callsreportCliFailure(parsed.json, ...)(a few lines below, in the main flow), but the--dry-runbranch's owncatchblock does a raw, unconditional:So
loopover-miner discover --dry-run --jsonon a fetch/rank failure prints plain text to stderr instead of parseable JSON to stdout — breaking any--json-consuming caller (CI, the MCP wrapper, a script) exactly when it most needs a structured error.test/unit/miner-discover-cli.test.ts's two "--dry-runreports fan-out failures" tests only exercise the non---jsoncase, so this combination is untested today.Requirements
--dry-runbranch'scatchblock inrunDiscover(packages/loopover-miner/lib/discover-cli.js) must callreportCliFailure(parsed.json, describeCliError(error))(or the equivalent already used by this file's non-dry-run path) instead of the rawconsole.error/return 2.--jsoncase must be unchanged (plain-text stderr output stays plain text).--dry-runhandling in this PR — this issue is scoped todiscover-cli.jsonly.Deliverables
runDiscover's--dry-runcatch block honors--jsonthe same way the non-dry-run path already doesloopover-miner discover --dry-run --jsonon a fetch/rank failure emits{ok:false,error}parseable JSON on stdout, exit code unchanged--json--dry-runfailure tests still pass unmodifiedTest Coverage Requirements
99%+ patch coverage (branch-counted) on the changed branch in
discover-cli.js.Expected Outcome
loopover-miner discover --dry-run --jsonon any fetch/rank failure prints valid, parseable{ok:false,error}JSON on stdout — matching every other command's--jsonerror contract in this package.Links & Resources
packages/loopover-miner/lib/discover-cli.js(runDiscover,--dry-runcatch block)packages/loopover-miner/lib/cli-error.js(reportCliFailure, the established contract)test/unit/miner-discover-cli.test.ts(existing--dry-runfailure tests to extend)