Skip to content

fix(miner): manage-poll.js --dry-run doesn't honor --json on failure #6054

Description

@JSONbored

Context

Same bug class as the discover-cli.js --dry-run --json gap and the two just-fixed commands (#5914/#6034, #6033): this repo's established JSON error-contract convention (packages/loopover-miner/lib/cli-error.js's reportCliFailure) requires every --json failure path to emit a parseable { ok: false, error } object on stdout instead of plain text on stderr.

packages/loopover-miner/lib/manage-poll.js's runManagePoll has the same gap in its --dry-run branch. The real (non-dry-run) failure path correctly calls reportCliFailure(parsed.json, ...), 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 manage-poll --dry-run --json on a failure prints plain text to stderr instead of parseable JSON. test/unit/miner-manage-poll.test.ts's "--dry-run reports poll failures" test only exercises the non---json case, so this combination is untested today.

Requirements

  • The --dry-run branch's catch block in runManagePoll (packages/loopover-miner/lib/manage-poll.js) must call reportCliFailure(parsed.json, describeCliError(error)) (or the equivalent this file's non-dry-run path already uses) instead of the raw console.error/return 2.
  • Behavior for the non---json case must be unchanged.
  • Scoped to manage-poll.js only — do not touch other commands in this PR.

Deliverables

  • runManagePoll's --dry-run catch block honors --json the same way the non-dry-run path already does
  • Test: loopover-miner manage-poll --dry-run --json on a failure emits {ok:false,error} parseable JSON on stdout, exit code unchanged
  • Test: the existing non---json --dry-run failure test still passes unmodified

Test Coverage Requirements

99%+ patch coverage (branch-counted) on the changed branch in manage-poll.js.

Expected Outcome

loopover-miner manage-poll --dry-run --json on any failure prints valid, parseable {ok:false,error} JSON on stdout — matching every other command's --json error contract in this package.

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions