jesseduffield/lazygit · error

unable to parse label format, error: {{err}}

Error message

unable to parse label format, error: {{err}}

What it means

When a menuFromCommand prompt specifies a `labelFormat`, MenuGenerator parses it as a Go text/template with color functions added. If parsing fails, this error wraps the underlying template syntax error. labelFormat is optional; when absent the valueTemplate is reused, so only an explicitly set bad labelFormat triggers this.

Source

Thrown at pkg/gui/services/custom_commands/menu_generator.go:76

	}

	regex, err := regexp.Compile(filter)
	if err != nil {
		return nil, errors.New("unable to parse filter regex, error: " + err.Error())
	}

	valueTemplateAux, err := template.New("format").Parse(valueFormat)
	if err != nil {
		return nil, errors.New("unable to parse value format, error: " + err.Error())
	}
	valueTemplate := NewTrimmerTemplate(valueTemplateAux)

	var labelTemplate *TrimmerTemplate
	if labelFormat != "" {
		colorFuncMap := style.TemplateFuncMapAddColors(template.FuncMap{})
		labelTemplateAux, err := template.New("format").Funcs(colorFuncMap).Parse(labelFormat)
		if err != nil {
			return nil, errors.New("unable to parse label format, error: " + err.Error())
		}
		labelTemplate = NewTrimmerTemplate(labelTemplateAux)
	} else {
		labelTemplate = valueTemplate
	}

	return func(line string) (*commandMenuItem, error) {
		return self.generateMenuItem(
			line,
			regex,
			valueTemplate,
			labelTemplate,
		)
	}, nil
}

func (self *MenuGenerator) generateMenuItem(
	line string,

View on GitHub (pinned to c477a2959b)

Solutions

  1. Fix the labelFormat template syntax (balanced '{{ }}', valid function names).
  2. Verify any piped function exists: built-ins plus the color helpers (e.g. green, yellow, bold) registered by style.TemplateFuncMapAddColors.
  3. If labels can equal values, remove labelFormat entirely to fall back to valueFormat.

Example fix

# before
    labelFormat: '{{.group_1 | grean}}'
# after
    labelFormat: '{{.group_1 | green}}'
Defensive patterns

Strategy: validation

Validate before calling

if prompt.LabelFormat != "" {
    if _, err := template.New("format").Funcs(style.TemplateFuncMapAddColors(template.FuncMap{})).Parse(prompt.LabelFormat); err != nil {
        return fmt.Errorf("bad labelFormat: %w", err)
    }
}

Prevention

When it happens

Trigger: A labelFormat with malformed template syntax: unclosed '{{', invalid action, or a pipe to a nonexistent function (only the color FuncMap from style.TemplateFuncMapAddColors plus builtins are available).

Common situations: Adding coloring like '{{.group_1 | green}}' with a typo in the function name, or broken braces while hand-editing config.yml.

Understand the failure class

Related errors


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