jesseduffield/lazygit · error

Error with custom command%s: it is not allowed to use both c

Error message

Error with custom command%s: it is not allowed to use both commandMenu and any of the other fields except key and description.

What it means

Raised by validateCustomCommands in pkg/config/user_config_validation.go. A custom command that sets commandMenu (a nested submenu) must not also set context, command, prompts, loadingText, output, outputTitle or after — only key and description are allowed alongside it. This prevents a command that is simultaneously an action and a menu.

Source

Thrown at pkg/config/user_config_validation.go:212

func validateCustomCommands(customCommands []CustomCommand) error {
	for _, customCommand := range customCommands {
		if err := validateCustomCommandKey(customCommand.Key); err != nil {
			return err
		}

		if len(customCommand.CommandMenu) > 0 {
			if len(customCommand.Context) > 0 ||
				len(customCommand.Command) > 0 ||
				len(customCommand.Prompts) > 0 ||
				len(customCommand.LoadingText) > 0 ||
				len(customCommand.Output) > 0 ||
				len(customCommand.OutputTitle) > 0 ||
				customCommand.After != nil {
				commandRef := ""
				if len(customCommand.Key) > 0 {
					commandRef = fmt.Sprintf(" with key '%s'", customCommand.Key.String())
				}
				return fmt.Errorf("Error with custom command%s: it is not allowed to use both commandMenu and any of the other fields except key and description.", commandRef)
			}

			if err := validateCustomCommands(customCommand.CommandMenu); err != nil {
				return err
			}
		} else {
			for _, prompt := range customCommand.Prompts {
				if err := validateCustomCommandPrompt(prompt); err != nil {
					return err
				}
			}

			if err := validateEnum("customCommand.output", customCommand.Output,
				[]string{"", "none", "terminal", "log", "logWithPty", "popup"}); err != nil {
				return err
			}
		}
	}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Split into two entries: keep the plain command in one and move commandMenu into its own entry (optionally with a different key/description).
  2. Or delete the extra fields so only key, description and commandMenu remain.
  3. Check YAML indentation — fields accidentally promoted to the parent entry look like violations.
  4. Restart lazygit to revalidate.

Example fix

# before
customCommands:
  - key: 'm'
    description: menu
    command: git status
    commandMenu:
      - key: 's'
        command: git stash

# after
customCommands:
  - key: 's'
    command: git status
  - key: 'm'
    description: menu
    commandMenu:
      - key: 't'
        command: git stash
Defensive patterns

Strategy: validation

Validate before calling

for _, cc := range cfg.CustomCommands {
	if len(cc.CommandMenu) > 0 && (cc.Command != "" || len(cc.Prompts) > 0 || cc.Context != "" || cc.Output != "" || cc.LoadingText != "" || cc.OutputTitle != "" || cc.After != nil) {
		return errors.New("commandMenu entries may only use key and description")
	}
}

Prevention

When it happens

Trigger: Writing a customCommands entry with both `commandMenu:` (non-empty list) and any of context/command/prompts/loadingText/output/outputTitle/after, then launching lazygit.

Common situations: Copying a working custom command and adding a submenu to it instead of starting fresh; indentation mistakes that leave the old fields at the same level as commandMenu; docs examples merged incorrectly.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/7a45455484a035c0. Report an issue: GitHub.