jesseduffield/lazygit · error
Invalid lazygit-edit URL format: %s
Error message
Invalid lazygit-edit URL format: %s
What it means
Thrown by lazygit's open-hyperlink handler (SetOpenHyperlinkFunc in pkg/gui/gui.go) when a clicked link starts with the 'lazygit-edit:' scheme but does not match the expected shape 'lazygit-edit://<filepath>' or 'lazygit-edit://<filepath>:<line>'. The regex '^lazygit-edit://(.+?)(?::(\d*))?$' requires the '//' authority separator and an optional all-digit line number. Any deviation (missing slashes, non-numeric line suffix, trailing colon with junk) makes FindStringSubmatch return nil and this error fires.
Source
Thrown at pkg/gui/gui.go:408
if err := gui.checkForChangedConfigsThatDontAutoReload(oldConfig, gui.Config.GetUserConfig()); err != nil {
return err
}
}
gui.c.Log.Info("Receiving focus - refreshing")
gui.helpers.Refresh.Refresh(types.RefreshOptions{DontBlockRepoSwitch: true})
return reloadErr
}
return nil
})
gui.g.SetOpenHyperlinkFunc(func(url string, viewname string) error {
if strings.HasPrefix(url, "lazygit-edit:") {
re := regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d*))?$`)
matches := re.FindStringSubmatch(url)
if matches == nil {
return fmt.Errorf(gui.Tr.InvalidLazygitEditURL, url)
}
filepath := matches[1]
if matches[2] != "" {
lineNumber := utils.MustConvertToInt(matches[2])
lineNumber = gui.helpers.Diff.AdjustLineNumber(filepath, lineNumber, viewname)
return gui.helpers.Files.EditFileAtLine(filepath, lineNumber)
}
return gui.helpers.Files.EditFiles([]string{filepath})
}
if err := gui.os.OpenLink(url); err != nil {
return fmt.Errorf(gui.Tr.FailedToOpenURL, url, err)
}
return nil
})
gui.g.SetUpdateQueueHighWaterMarkHandler(func(depth int) {View on GitHub (pinned to c477a2959b)
Solutions
- Fix the URL emitter to use exactly 'lazygit-edit://<path>' or 'lazygit-edit://<path>:<integer line>'
- If the link comes from a custom command template, check its output formatting for the lazygit-edit scheme
- If the link is supposed to be a normal web URL, remove the 'lazygit-edit:' prefix so it is handed to the OS opener instead
Example fix
// before (bad link producer)
fmt.Sprintf("lazygit-edit:%s:%d", path, line)
// after
fmt.Sprintf("lazygit-edit://%s:%d", path, line) Defensive patterns
Strategy: validation
Validate before calling
var lazygitEditRe = regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d*))?$`)
func validLazygitEditURL(url string) bool {
return !strings.HasPrefix(url, "lazygit-edit:") || lazygitEditRe.MatchString(url)
} Prevention
- Always format edit links as lazygit-edit://<path> or lazygit-edit://<path>:<line> with a numeric line
- Test link-emitting templates once after writing them by clicking the link in lazygit
When it happens
Trigger: Clicking a hyperlink rendered in any gocui view whose URL begins with 'lazygit-edit:' but is malformed, e.g. 'lazygit-edit:file.go' (no '//'), 'lazygit-edit://file.go:abc' (non-numeric line), or 'lazygit-edit://file.go:12:' (extra trailing segment). Emitted by custom command output, commit messages, or any text lazygit renders as a link.
Common situations: A user config or custom command templates a lazygit-edit link with a bad format string; a plugin/script writes an edit link missing the '//' separator; a template inserts an empty or non-numeric line number producing ':abc' or ':'.
Related errors
- Failed to open URL %s Error: %v
- Cannot change context while in patch building mode because w
- No patch created yet. To start building a patch, use 'space'
- Patch is still empty. Add some files or lines to your patch
- No config file found
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/7a609aff59ef292c.
Report an issue: GitHub.