Skip to content

v3.6.2 regression: flag parsing skipped for help subcommands #2271

@silverwind

Description

@silverwind

Filed by Claude on behalf of @silverwind

Description

PR #2245 introduced a regression in v3.6.2 where flag pre-parsing is skipped for any command named "help". This breaks applications that use flags with help subcommands, as the flags are never parsed.

The problematic change in command_run.go:

-	if cmd.isCompletionCommand {
+	if cmd.isCompletionCommand || cmd.Name == helpName {
		tracef("special command detected, skipping pre-parse (cmd=%[1]q)", cmd.Name)
		cmd.parsedArgs = args
		return ctx, cmd.Action(ctx, cmd)
	}

By matching on cmd.Name == helpName, this skips pre-parsing for ALL commands named "help", not just the internal completion command. This causes flags passed to help subcommands (e.g. myapp help -c mycmd) to be silently ignored.

Steps to reproduce

  1. Define a CLI app with a flag (e.g. -c) on the help command
  2. Run myapp help -c value
  3. The flag value is never parsed

Expected behavior

Flags should be parsed normally for help commands, as they were in v3.6.1.

Actual behavior

Flag pre-parsing is skipped entirely, flags are ignored.

Workaround

Pin urfave/cli/v3 to v3.6.1 or earlier via replace directive in go.mod.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions