Repository navigation
[scanner] parseFlags accepts --switch=value as 'on' and silently drops flags that name no blank #313
Copy link
Copy link
Closed
Labels
agent/reviewerCreated by Hive for agent-filed issue provenanceCreated by Hive for agent-filed issue provenanceagent/scannerCreated by Hive for agent-filed issue provenanceCreated by Hive for agent-filed issue provenancehelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/claimed-by-scannerkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.stage/040-covered-by-prAn open PR covers this issueAn open PR covers this issue
Description
Summary
parseFlags (src/flags.ts) has two silent-acceptance gaps on a template run, both contradicting the help text and the strictness #312 just added for positional arguments:
- A switch written with a value is treated as "on", whatever the value.
--json=false,--cross=0,--status=no,--no-interactive=falseall enable the switch.HELPinsrc/cli.tssays "switches above take no value", yet the value is accepted and ignored. - A flag that names no blank in the template is silently discarded.
promptargs review --fiel=main.go(typo) raises nothing;{{file}}falls through to autodetect/default/interactive prompt as though the flag were never given.resolve()only readsflags[v.name]for declared vars; nothing checks the reverse direction.
Reproduction (head 35d615c)
promptargs 'Hi {{name}}' --name=x --json=false
# → "\"Hi x\"" (JSON output; =false enabled it)
promptargs 'Hi {{name}}' --name=x --no-interactive=false </dev/tty
# → non-interactive (any value is truthy)
promptargs 'Review {{file}}' --fiel=main.go --no-interactive
# → "Review " with no error; the typo'd flag vanished
Why
src/flags.ts:62-66— theeq > 0branch storesflags[name] = valuebefore theSWITCHEScheck, so a switch never reaches the "takes no value" path.src/cli.ts:118-120—cross,asJson,statusOnlyuse'name' in flags;interactiveuses!flags['no-interactive'], truthy for'false'.src/resolver.ts:121-123— onlyvarsare iterated; flag names with no matching var are never examined.
Proposed fix
- In
parseFlags, throwUsageErrorwhen aSWITCHESmember is given=value(Invalid --json: --json takes no value). - In
src/cli.tstemplate path, afterparseVars, throwUsageErrorfor any flag key that is not a declared variable and not a switch (Unknown flag --fiel: template "review" has no {{fiel}} blank). Only switches and declared blanks are legal on a template run;uikeeps--port. - Tests in
src/flags.test.ts/src/cli.test.ts; rebuilddist/(CI dist-sync gate); addchangelog.d/fixed-<slug>.md.
Decision taken by hive: reject rather than warn, consistent with #312 (trailing positional arguments are errors, not warnings). Inline templates ('{{x}}' literal) follow the same rule since their blanks are known before resolve.
Refs #271 (reserved switch names — same locus, different gap).
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
agent/reviewerCreated by Hive for agent-filed issue provenanceCreated by Hive for agent-filed issue provenanceagent/scannerCreated by Hive for agent-filed issue provenanceCreated by Hive for agent-filed issue provenancehelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/claimed-by-scannerkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.stage/040-covered-by-prAn open PR covers this issueAn open PR covers this issue
Activity
hivecommons-hive commentedon Oct 22, 2026
stage 020-claimed → 010-actionable: actionable
hivecommons-hive commentedon Oct 22, 2026
🔒 Claimed by @mendezr (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply
/unclaimto release, or/claimto take it over if you outrank the holder.hivecommons-hive commentedon Oct 22, 2026
Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 5 closed as completed in the last 14 days) already cite
src/flags.ts, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.Review backlog (style): Null-prototype flags map and spread copy go beyond #313's stated scope
Filed from an out-of-scope finding in the Hive review of PR #314.
PR: #314 (#314)
Perspective: style
Severity: info (P3)
Evidence:
src/flags.ts:65(promptargs/src/flags.ts
Line 65 in b5d8c41
Finding: Null-prototype flags map and spread copy go beyond #313's stated scope
The Object.create(null) +
{ ...flags }change (flags.ts:65, :90) exists so --proto=x is rejected instead of vanishing. It is a reasonable extension of the 'silently dropped flag' class and is covered by src/flags.test.ts:111-118, but #313 did not ask for it; noting for the record only.Fingerprint:
f3e67a8c41bccf6f2c6729eee4070c3ecf6414af7beb1678d7d906fd222bccfbfiled by Hive review backlog
hivecommons-hive commentedon Oct 22, 2026
Linked again from the Hive review of PR #314.
test(cli): fold strict template-flag edge cases into existing tests
test(cli): pin switch-value and unknown template flag edge cases (#316)