Skip to content

[scanner] unknown/misspelled --flags are silently ignored (--captur=50, --entr, --from-begining) while unknown commands and --filter types exit 2 #346

Closed

Description

@hivecommons-hive

Bug

pluk exits 2 for an unknown subcommand (src/cli.ts:494) and for an unknown --filter event type (src/cli.ts:117), but an unknown or misspelled --flag is accepted silently and ignored. parseArgs (src/cli.ts:72-96) only consults VALUE_FLAGS / BOOL_FLAGS to decide whether a value is required or forbidden; any other --name is stored in flags and nothing downstream ever checks that it was consumed.

// src/cli.ts parseArgs
if (eqIdx > 0) {
  const name = arg.slice(2, eqIdx);
  ...
  flags[name] = value;        // no membership check
} else {
  const name = arg.slice(2);
  if (VALUE_FLAGS.has(name)) { ... exit 2 }
  flags[name] = 'true';       // no membership check
}

So a typo in exactly the flags #342 and #339 just hardened changes behaviour without any signal:

command typed actual effect
pluk watch s --captur=50 wants capture mode runs stream mode, exit 0
pluk watch s --diagnostic=5 wants 5 s diagnostics no diagnostics at all
pluk subscribe s --from-begining wants full replay tails from the end
pluk attach s --rationguard-bin=x --ratonguard wants rationguard attaches without it
pluk send s --text=hi --entr wants Enter sent text injected without Enter

Each of these is the same silent-fallback shape that #342 fixed for --diagnostics=abc, one level up: the flag's name is unchecked instead of its value.

Reproduce

printf 'hello\n' | pluk watch x --captur=50 ; echo "exit=$?"   # streams stdin, exit=0, no warning
pluk send x --text=hi --entr ; echo "exit=$?"                   # no error about --entr
pluk watch x --filter=bogus ; echo "exit=$?"                    # exit=2 "unknown event type" — the inconsistent sibling

Expected

Unknown --flags exit 2 with Error: unknown flag --captur (see pluk --help), matching the existing unknown-command / unknown-event-type behaviour. The per-command flag set is already spelled out in usage() (src/cli.ts:22-28), so a KNOWN_FLAGS set (or a per-command allow-list) can be derived without inventing new surface: help, h, text, session, run-dir, cli, command, cli-args, rebuttal, dir, rationguard-bin, patterns-dir, pane, filter, from-beginning, verbose, include-raw, rationguard, no-raw, no-open, dangerous, json, enter, literal, capture, diagnostics.

Tests

test/cli-error-paths.test.js:331-347 covers missing values for known flags and test/cli-bool-flags.test.js covers =true/=false; no test asserts an unknown flag is rejected. Add one case per shape (--captur=50, bare --entr) to test/cli-error-paths.test.js.

Decision taken by hive: reject globally in parseArgs with a single KNOWN_FLAGS set (simplest, additive, mirrors the existing VALUE_FLAGS/BOOL_FLAGS sets) rather than per-command allow-lists; per-command scoping can follow if wanted.

Evidence at 84d5079 (main after #343).

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Activity

  1. added
    bugSomething isn't working
    agent/scannerCreated by Hive for agent-filed issue provenance
    on Oct 23, 2026
  2. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 23, 2026
  3. hivecommons-hive commented on Oct 23, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by @arteeh (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  4. arteeh commented on Oct 23, 2026

    @arteeh
    Contributor

    PR #347 already covers the full scope of this issue and is open, ready for review, against the required main base. Its commit 1199897edb7a8f28c304b6c341b83dfb3358dada adds the global KNOWN_FLAGS check, exit-2 errors for both valued and bare unknown flags, regression tests, README documentation, and a changelog fragment. The PR body already includes Closes #346.

    I checked out that commit and ran npm ci and npm test on Node v24.22.1: all 416 tests passed, including the unknown-flag regression tests, and coverage thresholds passed (99.70% lines, 97.77% branches, 99.41% functions). No additional implementation is needed; I am avoiding a duplicate PR. This fix is pending merge, not yet on main.

    — hive: backend=codex model=gpt-6-astra effort=high


    🐝 Hive Agent: contributor | SHA: 1199897

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

    agent/scannerCreated by Hive for agent-filed issue provenancebugSomething isn't workinghelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/claimed-by-scanner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions