Skip to content

fix(cli): report CLI_UNAVAILABLE for planned commands given any argv - #27

Merged
2ynn merged 2 commits into
mainfrom
fix/cli/planned-commands
Sep 22, 2026
Merged

2ynn merged 2 commits into
mainfrom
fix/cli/planned-commands

Conversation

@2ynn

@2ynn 2ynn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Planned placeholder commands (declared in the surface but not implemented in build) used Args: cobra.NoArgs. Any positional argument or unknown flag therefore failed cobra parsing before RunE ran, and the user received a CLI_VALIDATION parse error (exit 2) with an "unknown command" message and a --dry-run hint for a command that has no request to preview. The same command invoked bare correctly reported CLI_UNAVAILABLE (exit 1).

newPlannedCmd in templates/templates/cli/intents.go.stmpl now declares Args: cobra.ArbitraryArgs and FParseErrWhitelist{UnknownFlags: true}, matching the sibling newCustomCmd placeholder, so the CLI_UNAVAILABLE branch is reached regardless of argv:

$ cli archive hello            → exit 1, Reason: CLI_UNAVAILABLE
$ cli archive --count 3        → exit 1, Reason: CLI_UNAVAILABLE
$ cli --agent-mode archive x   → exit 1, {"error_reason": "CLI_UNAVAILABLE", "error_type": "unsupported_error", "exit_code": 1}
$ cli archive --help           → exit 0, help (unchanged)
$ cli archive --usage          → exit 0, cmd "archive" ... (unchanged)

@2ynn
2ynn requested a review from a team as a code owner September 22, 2026 14:05
@2ynn
2ynn requested a review from speakeasybot September 22, 2026 14:05

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread templates/templates/cli/tests/primary/clierrors_test.go.stmpl
Comment thread zSDKs/sdk-cli/internal/cli/intents.go
Planned placeholder commands declared `Args: cobra.NoArgs`, so any
positional argument or unknown flag failed argument parsing before `RunE`
ran. The user then saw `unknown command`, `Reason: CLI_VALIDATION`, exit 2,
and a `--dry-run` hint for a command that has no request to preview. Bare
invocation of the same command correctly reported `CLI_UNAVAILABLE`, exit 1.

Match the custom-command placeholder: accept arbitrary args and whitelist
unknown flags so the `CLI_UNAVAILABLE` branch is reached regardless of what
the user typed. `--help` and `--usage` are unchanged.

Tests pin exit 1 across plain, agent and JSON modes for a planned command
with an argument and with an unknown flag, and the agent envelope reason,
error type and absence of parse-error text.
Assert the planned-command envelope error is marked rendered, matching
the sibling agent-mode matrix, so a regression that drops the sentinel
would print the error twice and fail here.

Add a review-variant test next to the existing planned `--usage` case
covering a positional argument and an unknown flag: both must exit 1
with `CLI_UNAVAILABLE`.
@2ynn
2ynn force-pushed the fix/cli/planned-commands branch from 1dc0fbf to 50a88c3 Compare September 22, 2026 14:43
@2ynn
2ynn added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 307dfdc Sep 22, 2026
149 checks passed
@2ynn
2ynn deleted the fix/cli/planned-commands branch September 22, 2026 17:03
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants