fix(runner): --help and unknown-flag guard for _cli_flag subcommands (issue #459) - #460
Conversation
…s (issue #459) Add _cli_flags_guard(known, usage) helper that: - exits 0 printing usage when --help or -h is present in argv - exits 1 with an error when any unrecognised --flag appears Apply it to all four _cli_flag-based subcommands: write_review_verdict_ledger, write_implementer_readiness_review, write_prd_review, record_prd_review_decision Before this fix, --help on write_review_verdict_ledger ran the function with all-empty inputs and wrote .map/<branch>/review-verdict-ledger.{json,md} plus artifact_manifest.json — silently corrupting the workflow state. Regression coverage: 11 new subprocess tests in TestCliFlagsGuard verify that --help exits 0 with no .map/ written, unknown flags exit 1 with no state written, and known flags are still accepted without interference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRqTf2dJArpwNUA59afq5i
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe change adds shared CLI flag validation to four state-writing subcommands. Help flags now print usage and exit successfully. Unknown flags now produce an error before state-writing functions run. Regression tests cover these behaviors. ChangesCLI flag validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit guards the flags tonight Comment |
Problem
python3 .map/scripts/map_step_runner.py write_review_verdict_ledger --helpexecuted the subcommand with all-empty inputs and wrote.map/<branch>/review-verdict-ledger.{json,md}plusartifact_manifest.jsoninstead of printing usage. The root cause: the_cli_flaghelper silently ignores every flag it doesn't recognise, including--helpand typos.The same gap existed in the three other
_cli_flag-based subcommands:write_implementer_readiness_review,write_prd_review, andrecord_prd_review_decision.Fix
Add
_cli_flags_guard(known: frozenset[str], usage: str)right after_cli_flagin the template source (templates_src/map/scripts/map_step_runner.py.jinja). The guard is called at the top of each_cli_flag-based dispatch branch, before any state-writing function is invoked:--help/-hanywhere insys.argv[2:]→ print usage text,sys.exit(0), no.map/writes--footoken not in theknownset → print error naming the offending flag(s),sys.exit(1), no.map/writesChanges
src/mapify_cli/templates_src/map/scripts/map_step_runner.py.jinja— new_cli_flags_guardhelper + guard calls in all 4 branchessrc/mapify_cli/templates/map/scripts/map_step_runner.py— rendered output.map/scripts/map_step_runner.py— dev-copy rendered outputtests/test_map_step_runner.py— 11 new subprocess tests inTestCliFlagsGuardcovering all 4 subcommands:--helpexits 0 with no.map/written, unknown flags exit 1 with no state written, known flags still acceptedTest run
Fixes #459.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VRqTf2dJArpwNUA59afq5i
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests