Skip to content

AMS: purge-cli.js arg-parse error path bypasses the --json contract #5915

Description

@JSONbored

Context

packages/loopover-miner/lib/purge-cli.js's runPurge (lines 168-170) handles the top-level arg-parse failure with console.error(parsed.error); return 2; instead of routing through the shared reportCliFailure/argsWantJson contract from cli-error.js that the rest of the CLI suite uses (see the related governor-pause-cli.js gap for the same bug class). The rest of runPurge's actual purge-result reporting is already correctly --json-aware — only this one parse-error path is affected.

loopover-miner purge --repo <bad-value> --json (or any other arg-parse failure) prints plain text to stderr instead of the documented {ok:false,error} JSON envelope, breaking script/automation consumers that always pass --json and expect a JSON response regardless of success/failure.

Requirements

  • The arg-parse error path in runPurge must route through reportCliFailure(argsWantJson(args), parsed.error) instead of the raw console.error/return 2.
  • Non---json behavior must be unchanged.

Deliverables

  • Fix the single error path in runPurge (lines ~168-170) to use the shared contract.
  • Add a regression test in test/unit/miner-purge-cli.test.ts covering the arg-parse error WITH --json (the existing test at lines 229-232 only covers the error without --json).

Test Coverage Requirements

99%+ Codecov patch target, branch-counted — both --json and non---json arms of the fixed path need direct tests.

Expected Outcome

loopover-miner purge --json on an arg-parse failure emits the standard {ok:false,error} JSON envelope, consistent with the rest of the module and the rest of the CLI suite.

Links & Resources

  • packages/loopover-miner/lib/cli-error.js — the shared contract.
  • Related: the same bug class in governor-pause-cli.js (filed separately, this is a narrower one-path instance).

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.gittensor:priorityMaintainer-selected Gittensor priority — scores a 1.5x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions