Skip to content

Do not rewrite args for an unmatched default command - #2547

Open
joshbarros wants to merge 1 commit into
urfave:mainfrom
joshbarros:fix/2544-default-command-unknown
Open

joshbarros wants to merge 1 commit into
urfave:mainfrom
joshbarros:fix/2544-default-command-unknown

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #2544

When DefaultCommand names a subcommand that doesn't exist, command_run.go still replaced cmd.parsedArgs with the default-command-prefixed slice, so the root Action received a positional argument the user never typed. The rewrite now only happens when cmd.Command() resolves the default command.

Adds a regression test with a typo in DefaultCommand; it fails without the change.

Validation: go test ./... passes.

When DefaultCommand names a subcommand that does not exist, the root command still replaced parsedArgs with the default-command-prefixed slice, so the root Action received a positional argument the user never typed. Only rewrite the args when Command() actually resolves the default command.

Adds a regression test for a typo in DefaultCommand.
@joshbarros
joshbarros requested a review from a team as a code owner November 17, 2026 09:44

This branch has not been deployed

No deployments
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.

Unmatched DefaultCommand name leaks into root Action args

1 participant