Skip to content

[Hackathon] fix(cli): help <typo> silently exits 0 inside command groups (root correctly exits 5) #418

Closed as not planned

Description

@Satianurag

Verified against (commit SHA or released version)

commit 988c035 (main HEAD; testsprite --version -> 0.14.0)

Discord Username / User ID

sati1325

What does this improvement do?

testsprite <group> help <typo> and testsprite <group> <typo> --help exit 0 and print the group's help, silently swallowing the misspelled subcommand — while the same shapes at root level correctly fail with exit 5 (error: unknown command '<name>'). The typo'd name is never reported.

Repro (no credentials needed):

$ testsprite help badcmd              -> exit 5, error: unknown command 'badcmd'   [correct]
$ testsprite test help badsub         -> exit 0, prints `testsprite test` help      [wrong]
$ testsprite test badsub --help       -> exit 0, prints `testsprite test` help      [wrong]
$ testsprite help test badsub         -> exit 0                                     [wrong]
$ testsprite project env help badsub  -> exit 0                                     [wrong]

Every command group behaves this way (test, project, project env, agent, ci, schedule, testlist, tunnel, auth, test code, test plan, schedule run). A script or agent that asks for a subcommand's help cannot tell — via exit code — whether that subcommand actually exists, and with --output json it gets a text help dump instead of the JSON VALIDATION_ERROR envelope.

Root cause: unknownRootCommandMaskedByHelp in src/index.ts runs inside an addHelpText('beforeAll') hook that bails unless context.command === program, so the unknown-command check only ever fires for root help. For group help, Commander's own "show parent help" fallback wins and throws commander.help -> exit 0.

Details / implementation notes

Fix generalizes the mask check into unknownCommandMaskedByHelp: walk the argument path down the command tree (skipping the argument of value-taking options like --output json), and report the first token that fails to resolve to a real subcommand whenever a help path is being rendered or a later --help/-h would mask the error. Covers help bad, <g> bad --help, <g> help bad, help <g> bad, and arbitrarily nested groups. Verified: valid help targets (test help run, test run --help, help test, project help env) still exit 0, and --output json emits the proper VALIDATION_ERROR envelope.

A PR with the fix + regression tests will follow referencing this issue.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added a commit that references this issue on Oct 16, 2026
    13e92c7
  2. Lexiie commented on Oct 19, 2026

    @Lexiie
    Contributor

    /assign

  3. testsprite-hob commented on Oct 19, 2026

    @testsprite-hob

    Thanks for the interest, @Lexiie! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it accepted once it is). Feel free to check back, or ping us on Discord if it's been quiet.

  4. fyZhang66 commented on Oct 20, 2026

    @fyZhang66
    Contributor

    Thanks — the inconsistency is real (the unknown-command guard only runs at the root). We're in the middle of rewriting the CLI's command surface, and help/typo handling will be redone as part of that, so we won't take a point fix on the current command tree. Closing this and #541; appreciate the PR.

  5. added
    wontfixThis will not be worked on
    and removed
    needs-triageNew issue/PR awaiting first triage
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathonCLI hackathon submissionswontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions