{"record":{"id":"7868108824e758e1","repo":"jesseduffield/lazydocker","slug":"noitemsmessage","errorCode":null,"errorMessage":"{NoItemsMessage}","messagePattern":"\\{NoItemsMessage\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/panels/side_list_panel.go","lineNumber":156,"sourceCode":"\t\treturn nil\n\t}\n\n\tmainView := self.Gui.GetMainView()\n\tmainView.Tabs = self.ContextState.GetMainTabTitles()\n\tmainView.TabIndex = self.ContextState.mainTabIdx\n\n\ttask := self.ContextState.GetCurrentMainTab().Render(item)\n\n\treturn self.Gui.QueueTask(task)\n}\n\nfunc (self *SideListPanel[T]) GetSelectedItem() (T, error) {\n\tvar zero T\n\n\titem, ok := self.List.TryGet(self.SelectedIdx)\n\tif !ok {\n\t\t// could probably have a better error here\n\t\treturn zero, errors.New(self.NoItemsMessage)\n\t}\n\n\treturn item, nil\n}\n\nfunc (self *SideListPanel[T]) HandleNextLine() error {\n\tself.SelectNextLine()\n\n\treturn self.HandleSelect()\n}\n\nfunc (self *SideListPanel[T]) HandlePrevLine() error {\n\tself.SelectPrevLine()\n\n\treturn self.HandleSelect()\n}\n\nfunc (self *SideListPanel[T]) HandleNextMainTab() error {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/jesseduffield/lazydocker/blob/7e7aadc2071d58031bf2daafca1fbd4093efc23f/pkg/gui/panels/side_list_panel.go#L138-L174","documentation":"SideListPanel.GetSelectedItem returns this error when List.TryGet(SelectedIdx) fails — i.e. the side panel's list is empty (or the selected index is out of range). NoItemsMessage is per-panel: 'No services', 'No containers', 'No images', 'No volumes', 'No networks', so the message reflects which panel had nothing selected. The code itself admits 'could probably have a better error here'.","triggerScenarios":"Calling GetSelectedItem (directly or via a keybinding handler like HandleNextLine/HandlePrevLine) on an empty side panel — e.g. the containers panel before the first docker ps refresh, or the volumes panel when the daemon has no volumes.","commonSituations":"Pressing navigation/action keys immediately after startup before the docker list populates; panels that are legitimately empty on fresh Docker installs (no images/volumes yet); a daemon connection that returns an empty list because of wrong context/permissions.","solutions":["Wait for the first list refresh to complete, then retry the action.","If the panel is genuinely empty, populate Docker first (pull an image, start a container) or switch panels.","Check that lazydocker is pointed at the right docker context/host if lists are unexpectedly empty.","Code-level: check List.Len() > 0 before calling GetSelectedItem or invoking key handlers."],"exampleFix":"// before\n item, err := panel.GetSelectedItem()\nif err != nil {\n    return err\n}\n\n// after\nif panel.List.Len() == 0 {\n    return nil // nothing to act on; ignore the keypress\n}\nitem, err := panel.GetSelectedItem()\nif err != nil {\n    return err\n}","handlingStrategy":"validation","validationCode":"if panel.List.Len() == 0 {\n    return nil // no selection possible; ignore action\n}\nitem, err := panel.GetSelectedItem()\nif err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"item, err := panel.GetSelectedItem()\nif err != nil {\n    if err.Error() == panel.NoItemsMessage {\n        return nil // benign: nothing selected\n    }\n    return err\n}","preventionTips":["Guard keybinding handlers with a list-length check before dereferencing the selection.","Treat NoItemsMessage errors as no-ops, not failures — panels are legitimately empty sometimes.","Ensure async list refreshes cannot leave SelectedIdx out of range when the list shrinks."],"tags":["ui","empty-list","keybinding","guard-clause"],"backgroundTag":null,"analyzedSha":"7e7aadc2071d58031bf2daafca1fbd4093efc23f","analyzedAt":"2026-08-15T09:51:48.093Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}