Skip to content

fix(cli): reject unknown --flags with exit 2 instead of silently ignoring them - #347

Merged
hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-346
Oct 23, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-346

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #346

Unknown or misspelled --flags (e.g. --captur=50, --entr) are now rejected by parseArgs with Error: unknown flag --name (see pluk --help) and exit 2, matching unknown commands and --filter types.

  • src/cli.ts: new KNOWN_FLAGS set (help, h, VALUE_FLAGS, BOOL_FLAGS, capture, diagnostics); empty names (--, --=x) are treated as unknown.
  • Tests in test/cli-error-paths.test.js.
  • README note and changelog.d/fixed-346.md.

— hive: agent=scanner

…ring them

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 23, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 23, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

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

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 23, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Style review (head 1199897)

  1. README note lands mid-paragraph and breaks the antecedent — README.md:150 inserts "Unknown or misspelled --flags also exit 2 …" inside the Health diagnostics (watch, subscribe) paragraph, between the --diagnostics value rule (:149) and "It writes one JSON line per period … to stderr" (:151). "It" now reads as referring to unknown flags, and a global CLI rule is filed under a diagnostics-only subsection. Move the sentence to the ## CLI Commands section (README.md:98) as its own line, next to where unknown-command/--filter exit-2 behaviour is described (:131).

  2. 'h' in KNOWN_FLAGS admits an undocumented --h that is then silently ignored — src/cli.ts:73 lists 'h', but help is only ever --help or single-dash -h (usage() src/cli.ts:36; wantsHelp src/cli.ts:457,462, where -h is a positional and never reaches parseArgs). So pluk watch s --h passes rejectUnknownFlag, sets flags.h='true', and nothing reads it — the exact silent-ignore shape #346 fixes. Drop 'h' (and 'help' is only reachable if wantsHelp is bypassed; keeping it is harmless). Advisory.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 23, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

…EADME note

Review follow-ups for #347:
- remove 'h' from KNOWN_FLAGS so `--h` is rejected like any other
  unknown flag (help is only --help / -h)
- move the unknown-flag exit-2 note from the diagnostics subsection to
  the CLI Commands section where the other global exit-2 notes live

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 23, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read src/cli.ts at ae13852 against the tree, not just the diff. This looks correct to me.

  • KNOWN_FLAGS (src/cli.ts:72-74) covers every flag the CLI actually reads: I enumerated all flags.x / flags['x'] reads in src/cli.ts (24 names) and each is in VALUE_FLAGS, BOOL_FLAGS, or the explicit help/capture/diagnostics entries. No existing flag becomes a false "unknown".
  • rejectUnknownFlag runs before the existing bool/value-shape checks in both the --name=value (src/cli.ts:93) and bare --name (src/cli.ts:101) branches, so the error ordering is consistent.
  • -h is single-dash and never reaches the -- branch (src/cli.ts:88, 457-462), so the single-letter help path is unaffected; dropping --h from the set in ae13852 was the right call.
  • Bare -- is rejected as an empty flag name. pluk never consumes -- as an argument separator itself (the only -- usages are internal tmux send-keys args in src/attach.ts:348 / src/send.ts:28), so nothing regresses.
  • node --test test/cli-error-paths.test.js on this head: 16 pass, 0 fail.

Body matches the diff (Closes #346, scope limited to parseArgs, tests, README, changelog fragment). No findings.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read src/cli.ts at ae13852 against the tree, not just the diff. This looks correct to me.

What I verified:

  • Every flag the CLI actually reads (flags.<name> / flags['<name>'], 24 distinct names in src/cli.ts) is present in KNOWN_FLAGS (src/cli.ts:72-74), so no existing flag becomes a false "unknown flag" error.
  • wantsHelp runs before parseArgs in main (src/cli.ts:453-473), so pluk watch --typo --help still prints usage instead of exiting 2.
  • Bare -- had no prior meaning in pluk's own parser — the only '--' in src/ are arguments handed to tmux send-keys (src/attach.ts:348, src/send.ts:28), so treating -- / --=x as unknown (src/cli.ts:88-91) regresses nothing.
  • node --test test/cli-error-paths.test.js on this head: 16/16 pass.

One nit, not blocking: the PR body still says KNOWN_FLAGS includes h, but ae13852 deliberately dropped it (the set is help + VALUE_FLAGS + BOOL_FLAGS + capture + diagnostics). Worth updating the description so it matches the code.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 09d6d0f into main Oct 23, 2026
9 of 10 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-346 branch October 23, 2026 12:10
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#347ae13852` sha256:41bb7c9091c6dfb20769137c4422791b9f9b5c5d3cd53a1ca68358e23dfbd8ff — download from the dashboard or `hivectl review evidence #347`.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

0 participants