jesseduffield / jesseduffield/lazygit

Nil pointer on *RemoteBranch.FullName

Open
#3,521 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

**Describe the bug**
Lazygit panics due to nil pointer dereference. I'm happy to PR a change that makes the relevant function more defensive if need be, but i'm unfamiliar with the src so not sure where else I'd have to check

**To Reproduce**
Unfortunately not able to reproduce since I'm not exactly sure what caused it / what I did before hand.

**Expected behavior**
N/A

**Screenshots**
![image](https://github.com/jesseduffield/lazygit/assets/10516792/174c74f0-7277-4355-83b4-7eb8f84a3949)

**Version info:**
commit=, build date=, build source=homebrew, version=0.41.0, os=darwin, arch=arm64, git version=2.39.3 (Apple Git-146)
git version 2.39.3 (Apple Git-146)

**Additional context**
```bash
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x1049ff3b8]

goroutine 898521 [running]:
github.com/jesseduffield/lazygit/pkg/commands/models.(*RemoteBranch).FullName(0x140008bfec0?)
github.com/jesseduffield/lazygit/pkg/commands/models/remote_branch.go:10 +0x18
github.com/jesseduffield/lazygit/pkg/gui/context.NewRemoteBranchesContext.func3.GetRemoteBranchListDisplayStrings.1(0x0, 0x140014f7e50?)
github.com/jesseduffield/lazygit/pkg/gui/presentation/remote_branches.go:12 +0x30
github.com/samber/lo.Map[...]({0x140000bafa0?, 0x2, 0x104b76990}, 0x14001229c80?)
github.com/samber/lo@v1.31.0/slice.go:29 +0x80
github.com/jesseduffield/lazygit/pkg/gui/presentation.GetRemoteBranchListDisplayStrings(...)
github.com/jesseduffield/lazygit/pkg/gui/presentation/remote_branches.go:11
github.com/jesseduffield/lazygit/pkg/gui/context.NewRemoteBranchesContext.func3(0x10?, 0x1056a1c60?)
github.com/jesseduffield/lazygit/pkg/gui/context/remote_branches_context.go:32 +0x98
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0x140001a9610, 0xffffffffffffffff, 0xffffffffffffffff)
github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:88 +0x160
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0x140001a9600)
github.com/jesseduffield/lazygit/pkg/gui/context/list_context_trait.go:96 +0x44
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0x14000294908, {0x10504fd28, 0x1400000e690})
github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:139 +0x98
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0x1400001e400?, {0x10504fd28?, 0x1400000e690?})
github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:33 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshView(0x14000293280, {0x10504fd28, 0x1400000e690})
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:732 +0x50
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshRemotes(0x14000293280)
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:657 +0x1b0
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.9()
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:163 +0x20
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1.1({0x0?, 0x1049fd200?})
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:108 +0x24
github.com/jesseduffield/gocui.(*Gui).onWorkerAux(0x1049fd0f0?, 0x140011b41b0?, {0x105043238?, 0x14000711100?})
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:680 +0x6c
github.com/jesseduffield/gocui.(*Gui).OnWorker.func1()
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:667 +0x34
created by github.com/jesseduffield/gocui.(*Gui).OnWorker in goroutine 898317
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:666 +0x94
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.