{"record":{"id":"bac24c36c034a852","repo":"jesseduffield/lazygit","slug":"unable-to-parse-filter-regex-error-err","errorCode":null,"errorMessage":"unable to parse filter regex, error: {{err}}","messagePattern":"unable to parse filter regex, error: (.+?)\\}","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gui/services/custom_commands/menu_generator.go","lineNumber":62,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\t\tmenuItems = append(menuItems, menuItem)\n\t}\n\n\treturn menuItems, nil\n}\n\nfunc (self *MenuGenerator) getMenuItemFromLinefn(filter string, valueFormat string, labelFormat string) (func(line string) (*commandMenuItem, error), error) {\n\tif filter == \"\" && valueFormat == \"\" && labelFormat == \"\" {\n\t\t// showing command output lines as-is in suggestions panel\n\t\treturn func(line string) (*commandMenuItem, error) {\n\t\t\treturn &commandMenuItem{label: line, value: line}, nil\n\t\t}, nil\n\t}\n\n\tregex, err := regexp.Compile(filter)\n\tif err != nil {\n\t\treturn nil, errors.New(\"unable to parse filter regex, error: \" + err.Error())\n\t}\n\n\tvalueTemplateAux, err := template.New(\"format\").Parse(valueFormat)\n\tif err != nil {\n\t\treturn nil, errors.New(\"unable to parse value format, error: \" + err.Error())\n\t}\n\tvalueTemplate := NewTrimmerTemplate(valueTemplateAux)\n\n\tvar labelTemplate *TrimmerTemplate\n\tif labelFormat != \"\" {\n\t\tcolorFuncMap := style.TemplateFuncMapAddColors(template.FuncMap{})\n\t\tlabelTemplateAux, err := template.New(\"format\").Funcs(colorFuncMap).Parse(labelFormat)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"unable to parse label format, error: \" + err.Error())\n\t\t}\n\t\tlabelTemplate = NewTrimmerTemplate(labelTemplateAux)\n\t} else {\n\t\tlabelTemplate = valueTemplate","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/services/custom_commands/menu_generator.go#L44-L80","documentation":"MenuGenerator.getMenuItemFromLinefn compiles the `filter` field of a 'menuFromCommand' prompt as a Go regexp. If regexp.Compile fails (invalid regex syntax), this error wraps the underlying compile failure. The filter is applied to each line of the command output to extract menu entries.","triggerScenarios":"A menuFromCommand prompt whose filter string is not valid Go regexp syntax: unbalanced parentheses, invalid escapes like '\\d{' unterminated, unsupported PCRE constructs (e.g. lookaheads '(?=...)' which Go's RE2 does not support).","commonSituations":"Copy-pasting a PCRE/JavaScript regex with lookaheads or backreferences into config.yml; forgetting that Go uses RE2; unescaped special characters in an intended literal filter.","solutions":["Fix the regex in the prompt's filter field to be valid RE2 syntax (drop lookaheads/backreferences, balance groups).","Test the pattern with Go: `go run` a one-liner calling regexp.Compile, or use an RE2-compatible tester rather than a PCRE tester.","If you meant a literal string, escape regex metacharacters or use a simpler pattern."],"exampleFix":"# before\nprompts:\n  - type: menuFromCommand\n    command: 'git branch'\n    filter: 'branch (?=origin)'   # lookahead unsupported\n# after\nprompts:\n  - type: menuFromCommand\n    command: 'git branch'\n    filter: 'origin/.*'","handlingStrategy":"validation","validationCode":"// Validate the filter before shipping the config:\nif _, err := regexp.Compile(prompt.Filter); err != nil {\n    return fmt.Errorf(\"bad filter for prompt %q: %w\", prompt.Title, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test every menuFromCommand filter with Go's RE2 engine (PCRE-only constructs are unsupported).","Prefer simple capture patterns over clever regexes in config files.","Add a config lint step (regex + template compilation) to your dotfiles CI."],"tags":["config","regex","custom-commands","menu"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}