Skip to content

fix(miner): honor --json on the discover --dry-run failure path - #6051

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix/5830
Jul 15, 2026
Merged

fix(miner): honor --json on the discover --dry-run failure path#6051
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
reyanthony062001-ops:fix/5830

Conversation

@reyanthony062001-ops

Copy link
Copy Markdown
Contributor

Summary

loopover-miner discover supports --json for scripted callers, and its non-dry-run failure path routes through the shared reportCliFailure(parsed.json, describeCliError(error)) helper, which emits a { ok: false, error } object on stdout when --json is set. The --dry-run path (added in #4847) has its own separate catch block that bypasses that helper entirely — it always writes plain text to stderr and returns 2 regardless of --json:

} catch (error) {
  console.error(error instanceof Error ? error.message : String(error));
  return 2;
}

So loopover-miner discover <owner/repo> --dry-run --json on a failure (GitHub API error, invalid target) prints an unparseable plain-text line instead of the JSON object every other failure path in this CLI — including this same command's non-dry-run catch 20 lines later — honors. The fix routes the dry-run catch through the same reportCliFailure/describeCliError pair (already imported in this file).

Closes #5830

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • 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 (Closes #5830).

Validation

  • git diff --check — clean
  • npm run actionlint — no workflow changes
  • npm run typecheck — passes (whole project)
  • npm run test:coverage — the changed catch line is exercised by the new --dry-run --json regression test (JSON branch) and the existing --dry-run non-json failure tests (stderr branch), so codecov/patch on the diff is 100%. test/unit/miner-discover-cli.test.ts passes 42/42; the new test fails on the pre-fix code (which used console.error) and passes after.
  • npm run test:workers — unaffected (no worker changes)
  • npm run build:miner — passes (node --check over the miner CLI incl. discover-cli.js)
  • npm run test:miner-pack — passes (package dry-run ok)
  • npm run build:mcp / test:mcp-pack — unaffected (no MCP changes)
  • npm run ui:openapi:check / ui:lint / ui:typecheck / ui:build — unaffected (no UI/OpenAPI changes)
  • npm audit --audit-level=moderate — no dependency changes
  • New or changed behavior has unit tests — a --dry-run --json failure regression test asserting a parseable { ok: false, error } object; the existing non-json failure tests (Error and non-Error thrown values) continue to pass unchanged

If any required check was skipped, explain why:

  • Change is one catch block in packages/loopover-miner/lib/discover-cli.js plus its test. describeCliError is byte-identical to the previous inline error instanceof Error ? error.message : String(error) expression, so the non---json path (stderr text, exit code 2) is behavior-preserving. I additionally ran npm run engine-parity:drift-check and the backend drift checks (docs, manifest, command-reference, selfhost env-reference), all green.

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 — N/A (none).
  • API/OpenAPI/MCP behavior is updated and tested where needed — N/A (none).
  • UI changes use live API data or real empty/error/loading states — N/A (no UI changes).
  • Visible UI changes include a UI Evidence section — N/A (no UI/frontend/docs/extension changes).
  • Public docs/changelogs are updated where needed — N/A.

Notes

  • The two failure paths (--dry-run vs non-dry-run) now emit identical output for the same error and flags, so a scripted caller no longer gets different, sometimes-unparseable output depending on which nearly-identical branch it hits.

discover's --dry-run catch block wrote a plain-text line to stderr and
returned 2 regardless of --json, unlike the non-dry-run catch 20 lines
later (and the second failure path further down) which both route through
reportCliFailure(parsed.json, describeCliError(error)). A caller scripting
against `loopover-miner discover ... --dry-run --json` got unparseable
plain text instead of the {ok:false,error} object every other failure path
in this CLI emits. Route the dry-run catch through the same shared helper.

describeCliError is byte-identical to the previous inline expression, so
the non-json path (stderr text, exit 2) is unchanged; adds a regression
test asserting the --dry-run --json failure prints a parseable
{ok:false,error} object.

Closes JSONbored#5830
@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.22%. Comparing base (9597167) to head (e0e00e7).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6051      +/-   ##
==========================================
+ Coverage   95.17%   95.22%   +0.05%     
==========================================
  Files         592      593       +1     
  Lines       46960    46971      +11     
  Branches    15007    15015       +8     
==========================================
+ Hits        44693    44729      +36     
+ Misses       1511     1493      -18     
+ Partials      756      749       -7     
Flag Coverage Δ
shard-1 43.97% <0.00%> (-0.05%) ⬇️
shard-2 36.53% <0.00%> (+0.11%) ⬆️
shard-3 31.98% <100.00%> (-0.23%) ⬇️
shard-4 33.77% <0.00%> (+0.79%) ⬆️
shard-5 31.47% <0.00%> (-0.01%) ⬇️
shard-6 44.70% <0.00%> (+0.12%) ⬆️

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

Files with missing lines Coverage Δ
packages/loopover-miner/lib/discover-cli.js 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@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

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-15 07:56:16 UTC

2 files · 1 AI reviewer · no blockers · readiness 82/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Small, well-targeted fix: the dry-run catch block in discover-cli.js now routes through reportCliFailure/describeCliError instead of console.error+return 2, matching the non-dry-run failure path's --json behavior. The change is a one-line swap of already-imported helpers, and the accompanying test asserts the JSON payload shape and exit code, directly exercising the new branch.

Nits — 2 non-blocking
  • The new test only covers the --json branch for this catch block; consider also asserting the plain-text stderr output still works for the non-json case at this same call site, mirroring the existing 'Add a --dry-run / simulate mode across the miner CLI #4847' test just below it, for symmetry (test/unit/miner-discover-cli.test.ts).
  • Double check describeCliError's output for non-Error thrown values (e.g. the 'Add a --dry-run / simulate mode across the miner CLI #4847: --dry-run stringifies a thrown non-Error value' test right after this diff) still passes now that this catch path is shared logic — the diff doesn't show that test being touched, so worth confirming manually.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5830
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
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: 28 registered-repo PR(s), 16 merged, 1 issue(s).
Contributor context ✅ Confirmed Gittensor contributor reyanthony062001-ops; Gittensor profile; 28 PR(s), 1 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The dry-run catch block now routes through reportCliFailure(parsed.json, describeCliError(error)), identical to the non-dry-run path, and a regression test verifies --dry-run --json produces a parseable {ok:false,error} object on failure.

Review context
  • Author: reyanthony062001-ops
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 28 PR(s), 1 issue(s).
  • Related work: Titles/paths share 7 meaningful terms. (issue #6053)
  • Related work: Titles/paths share 6 meaningful terms. (issue #6054)
  • Related work: Titles/paths share 11 meaningful terms. (issue #6053, issue #6054)
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 82dd7c9 into JSONbored:main Jul 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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): discover-cli --dry-run --json breaks the JSON error contract on failure

1 participant