CommandArgParser: no test for a non-repeated flag given twice, and last-wins reverses the previous first-wins #548
Labels
No labels
agent-ready
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-human
needs-input
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#548
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
core/model/CommandArgParser.scala:212 does
bag.strings.updated(name, value), which overwrites, where the helper it replaced used .collectFirst and pinned first-wins with a test. There is no test for a non-repeated flag supplied twice. This affects every valued flag on all six kanon plugin commands.Type: bug
Filed from:
/home/mph/ops/kanon-DEVDOCS-246on branchDEVDOCS-246Intake: needs-input
The test gap is real:
--badge, a declared repeatable flag, is the only flag appearing twice anywhere incore/test/CommandArgParserTest.scala. But no document settles which rule a test would assert, so the gap cannot be closed without a decision.Two facts correct the issue text, and they matter for the decision:
strings.updated(name, stored)(0c06acdf^:core/model/CommandArgParser.scala:136), so last-wins reverses nothing inside this parser..collectFirstthat rewrite removed found a missing required flag, not a value. The first-wins behaviour lived in the per-command helpersIssueCreateParser.extractFlagValueandFeedbackParser.extractFlagValue(bothargs.indexOf), deleted on purpose in IW-463 Phase 5 — and neither carried a test pinning first-wins.Why no source settles it: the IW-463 2026-09-03 ruling covers only values beginning with
--, not repetition; the parser doc comments are silent; the repo runs both rules live (CommandArgParserlast-wins,ReviewStateCliParser.extractFlagfirst-wins); and the external convention is split — clap refuses a duplicated non-multiple arg by default, POSIX Guideline 11 prescribes only "interpreted in the order specified", and GNUgetoptleaves the policy to the utility.1. When a valued flag that is NOT declared repeatable is given twice (for example
iw issue create --title A --title B), which must hold?review-stateflag helper still does.Choosing (a) makes the work a test plus a doc line. (b) and (c) change behaviour on every valued flag of every declared command.
2.
review-state writeandreview-state updatedo not go through the declared parser; they read flags with a helper that takes the first occurrence. Should they be brought to the same rule as your answer above, or is that a separate issue?Note on part (i) of the issue: a characterization test pinning today's behaviour is not independent of this decision — it is option (a).
Not a duplicate of #549, #550 or #552: each names a different branch of the same function, and fixing any of them leaves the duplicate-flag case untested.
1: a, 2: yes, same rules
Intake: agent-ready
Workflow: diagnostic
Reason: all gates passed
Analysis: project-management/issues/IW-548/analysis.md on branch IW-548