Skip to content

fix(miner): honor --json on the manage-poll --dry-run failure path - #6072

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6054
Jul 15, 2026
Merged

fix(miner): honor --json on the manage-poll --dry-run failure path#6072
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6054

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

Summary

loopover-miner manage poll <owner/repo> <pr#>'s 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 branch 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 manage-poll <owner/repo> <pr#> --dry-run --json on a failure (e.g. a GitHub API error from the CI-check-run poll) 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 — honors. This fix routes the dry-run catch through the same reportCliFailure/describeCliError pair (already imported in this file), matching the same bug class already fixed in discover-cli.js (#5914/#6034, #6033, #5830/#6051).

Closes #6054

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 #6054).

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, unmodified) still pass, so codecov/patch on the diff is 100%. test/unit/miner-manage-poll.test.ts passes 9/9; 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. manage-poll.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 — 0 vulnerabilities (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/manage-poll.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.

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.

Closes JSONbored#6054

The --dry-run branch's catch block in runManagePoll wrote plain text to
stderr on failure regardless of --json, unlike the non-dry-run path which
already routes through reportCliFailure/describeCliError. Route the
dry-run catch through the same helpers so --dry-run --json emits a
parseable {ok:false,error} object on stdout, matching every other
command's --json error contract in this CLI.
@nghetienhiep
nghetienhiep requested a review from JSONbored as a code owner July 15, 2026 08:17
@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.23%. Comparing base (d882f1a) to head (c781add).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6072   +/-   ##
=======================================
  Coverage   95.22%   95.23%           
=======================================
  Files         595      595           
  Lines       46998    47008   +10     
  Branches    15015    15015           
=======================================
+ Hits        44756    44766   +10     
  Misses       1493     1493           
  Partials      749      749           
Flag Coverage Δ
shard-1 43.94% <0.00%> (-0.08%) ⬇️
shard-2 36.56% <0.00%> (+0.07%) ⬆️
shard-3 31.89% <0.00%> (-0.06%) ⬇️
shard-4 31.97% <100.00%> (-1.06%) ⬇️
shard-5 32.66% <0.00%> (+1.15%) ⬆️
shard-6 44.68% <0.00%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
packages/loopover-miner/lib/manage-poll.js 97.89% <100.00%> (-0.03%) ⬇️

@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 08:32:26 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a small, correctly-scoped fix that routes the manage-poll --dry-run catch block through the same reportCliFailure/describeCliError helper already used by the non-dry-run path, so --dry-run --json now emits a parseable {ok:false,error} object instead of a plain-text stderr line on failure. The diff matches the described bug class and the accompanying test asserts the JSON shape and exit code 2, and correctly checks that the queue/ledger init functions are not called on this failure path. The existing #4847 non-JSON stderr test remains adjacent and unmodified, confirming the stderr branch still works when --json is absent.

Nits — 2 non-blocking
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #6054
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: 70 registered-repo PR(s), 36 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetienhiep; Gittensor profile; 70 PR(s), 0 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 calls reportCliFailure(parsed.json, describeCliError(error)) exactly matching the non-dry-run path's contract, and a new test confirms --dry-run --json emits parseable {ok:false,error} JSON while the existing non-json test remains unmodified.

Review context
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 24cb0e5 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): manage-poll.js --dry-run doesn't honor --json on failure

1 participant