jesseduffield / jesseduffield/lazydocker

panic: runtime error: index out of range [0] in GetContainers (v0.24.2)

Open
#754 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
52.8k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Lazydocker panics and crashes immediately upon startup with a `runtime error: index out of range [0] with length 0`. Before the crash, the terminal displays raw ANSI escape sequences (mouse tracking codes) because the TUI fails to initialize properly due to the panic occurring during the initial container refresh.

**To Reproduce**
Steps to reproduce the behavior:

1. Open Kitty terminal (or any terminal with `xterm-kitty` TERM).
2. Run `lazydocker`.
3. The app crashes immediately, dumping a stack trace.

**Expected behaviour**
The application should load the dashboard and list containers without crashing, even if certain Docker objects (containers or networks) have unusual or empty attributes.

**Screenshots**
*(Attach the image you have showing the "Matrix" numbers and the broken UI layout)*

**Desktop (please complete the following information):**

* **OS:** Linux (amd64)
* **Lazydocker Version:** v0.24.2
* **Terminal:** xterm-kitty

**Additional context**
The crash occurs specifically in the `GetContainers` function. It seems to be an edge case where an expected slice is empty.

**Stack Trace:**

```text
panic: runtime error: index out of range [0] with length 0

goroutine 37 [running]:
github.com/jesseduffield/lazydocker/pkg/commands.(*DockerCommand).GetContainers(0xc0000df500, {0x0, 0x0, 0x0?})
github.com/jesseduffield/lazydocker/pkg/commands/docker.go:259 +0x82f
github.com/jesseduffield/lazydocker/pkg/commands.(*DockerCommand).RefreshContainersAndServices(0xc0000df500, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0})
github.com/jesseduffield/lazydocker/pkg/commands/docker.go:185 +0x125
github.com/jesseduffield/lazydocker/pkg/gui.(*Gui).refreshContainersAndServices(0xc00039a000)
github.com/jesseduffield/lazydocker/pkg/gui/containers_panel.go:258 +0xd5
github.com/jesseduffield/lazydocker/pkg/gui.(*Gui).refresh.func2()
github.com/jesseduffield/lazydocker/pkg/gui/gui.go:305 +0x1c
created by github.com/jesseduffield/lazydocker/pkg/gui.(*Gui).refresh in goroutine 55
github.com/jesseduffield/lazydocker/pkg/gui/gui.go:304 +0x96

```

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.