jesseduffield/lazygit · error

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

Error message

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

What it means

MenuGenerator.getMenuItemFromLinefn parses the `valueFormat` field of a menuFromCommand prompt as a Go text/template. If template.New("format").Parse(valueFormat) fails (malformed template syntax), this error wraps the parse failure. valueFormat turns each captured regex group into the menu item's value.

Source

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

	return menuItems, nil
}

func (self *MenuGenerator) getMenuItemFromLinefn(filter string, valueFormat string, labelFormat string) (func(line string) (*commandMenuItem, error), error) {
	if filter == "" && valueFormat == "" && labelFormat == "" {
		// showing command output lines as-is in suggestions panel
		return func(line string) (*commandMenuItem, error) {
			return &commandMenuItem{label: line, value: line}, nil
		}, nil
	}

	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,

View on GitHub (pinned to c477a2959b)

Solutions

  1. Correct the valueFormat template so every '{{' has a matching '}}' and actions are valid, e.g. '{{.group_1}}'.
  2. Check the adjacent labelFormat too — it is parsed right after and fails similarly.
  3. Reload config and rerun the custom command.

Example fix

# before
    valueFormat: '{{.group_1'   # missing }}
# after
    valueFormat: '{{.group_1}}'
Defensive patterns

Strategy: validation

Validate before calling

if _, err := template.New("format").Parse(prompt.ValueFormat); err != nil {
    return fmt.Errorf("bad valueFormat for prompt %q: %w", prompt.Title, err)
}

Prevention

When it happens

Trigger: A valueFormat with unbalanced '{{' / '}}', unknown function names, or invalid template syntax such as '{{ .group_1 ' (missing closing braces) or '{{if}}' without end.

Common situations: Typing a template placeholder wrong in config.yml; forgetting the closing '}}' when editing '{{.group_1}}'; using a function not in the template FuncMap.

Understand the failure class

Related errors


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