Skip to content

Add check for missing --name or --all options + integration test#53

Open
mikusaq wants to merge 1 commit into
masterfrom
BAF-1330/cmdparse-better-error
Open

Add check for missing --name or --all options + integration test#53
mikusaq wants to merge 1 commit into
masterfrom
BAF-1330/cmdparse-better-error

Conversation

@mikusaq
Copy link
Copy Markdown
Contributor

@mikusaq mikusaq commented May 15, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced command-line argument validation for build-package and build-app commands.
    • Tool now requires either --name or --all flags to be specified.
    • Improved error messages for invalid argument combinations.
  • Tests

    • Added integration tests to verify argument validation behavior.

Review Change Stack

Add integration tests for this edge case.
@mikusaq mikusaq self-assigned this May 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

The PR adds CLI argument validation to enforce that build-package and build-app modes require either --name or --all to be specified. A new checkInvalidOptionCombinations helper is introduced in the argument parsing flow, and two integration tests verify that the validation errors are correctly reported.

Changes

CLI Validation Enhancement

Layer / File(s) Summary
Validation helper implementation
cmd/bap-builder/CmdArgs.go
ParseArgs now calls checkInvalidOptionCombinations() to validate CLI arguments. The new helper enforces that both build-package and build-app require either --name or --all, and validates existing build-package-specific incompatible flag combinations like --all vs --build-deps* and mutually exclusive --build-deps-on vs --build-deps-on-recursive.
Integration tests for validation
tests/integration_tests/test_invalid_arguments.py
Two new tests (test_06_build_package_without_name_or_all and test_07_build_app_without_name_or_all) verify that invoking build-package or build-app without --name or --all returns a command-line error with "ERROR" in the output.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A builder needs a name or all,
No flags? Then validation will call!
New tests now ensure,
The errors are pure,
One more step to answer the call! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding validation for missing --name or --all options with corresponding integration tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BAF-1330/cmdparse-better-error

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/integration_tests/test_invalid_arguments.py (1)

93-94: ⚡ Quick win

Assert the specific validation message, not just generic "ERROR"

Line 93 and Line 109 only verify a generic failure marker, so these tests can pass for unrelated errors. Assert the new contract message (requires either --name or --all) to lock this behavior.

Proposed test hardening
 def test_06_build_package_without_name_or_all(test_image, packager_binary, context, test_repo):
@@
-    assert "ERROR" in stdout
+    assert "ERROR" in stdout
+    assert "build-package requires either --name or --all" in stdout
@@
 def test_07_build_app_without_name_or_all(test_image, packager_binary, context, test_repo):
@@
-    assert "ERROR" in stdout
+    assert "ERROR" in stdout
+    assert "build-app requires either --name or --all" in stdout

Also applies to: 109-109

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration_tests/test_invalid_arguments.py` around lines 93 - 94,
Replace the weak generic assertions that check for "ERROR" in stdout with a
precise assertion for the validation message; update the assertions that
currently read assert "ERROR" in stdout to assert "requires either --name or
--all" in stdout (apply to both occurrences that reference stdout) so the tests
verify the exact contract message rather than a generic error marker.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/integration_tests/test_invalid_arguments.py`:
- Around line 93-94: Replace the weak generic assertions that check for "ERROR"
in stdout with a precise assertion for the validation message; update the
assertions that currently read assert "ERROR" in stdout to assert "requires
either --name or --all" in stdout (apply to both occurrences that reference
stdout) so the tests verify the exact contract message rather than a generic
error marker.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae2aeb9c-55ae-4e0b-8aa4-8c403740f2c3

📥 Commits

Reviewing files that changed from the base of the PR and between acf4a4e and f7ebe9e.

📒 Files selected for processing (2)
  • cmd/bap-builder/CmdArgs.go
  • tests/integration_tests/test_invalid_arguments.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant