{"record":{"id":"5d924beb142b316a","repo":"gitui-org/gitui","slug":"no-valid-branch-selected","errorCode":null,"errorMessage":"no valid branch selected","messagePattern":"no valid branch selected","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"src/popups/branchlist.rs","lineNumber":582,"sourceCode":"\t\t\t\tformat!(\"{branch_name:branch_name_length$} \"),\n\t\t\t\ttheme.branch(selected, is_head),\n\t\t\t);\n\n\t\t\ttxt.push(Line::from(vec![\n\t\t\t\tspan_prefix,\n\t\t\t\tspan_name,\n\t\t\t\tspan_hash,\n\t\t\t\tspan_msg,\n\t\t\t]));\n\t\t}\n\n\t\tText::from(txt)\n\t}\n\n\t///\n\tfn switch_to_selected_branch(&mut self) -> Result<()> {\n\t\tif !self.valid_selection() {\n\t\t\tanyhow::bail!(\"no valid branch selected\");\n\t\t}\n\n\t\tlet status = sync::status::get_status(\n\t\t\t&self.repo.borrow(),\n\t\t\tStatusType::WorkingDir,\n\t\t\tNone,\n\t\t)\n\t\t.expect(\"Could not get status\");\n\n\t\tlet selected_branch = &self.branches[self.selection as usize];\n\t\tif status.is_empty() {\n\t\t\tif self.local {\n\t\t\t\tcheckout_branch(\n\t\t\t\t\t&self.repo.borrow(),\n\t\t\t\t\t&selected_branch.name,\n\t\t\t\t)?;\n\t\t\t\tself.hide();\n\t\t\t} else {","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/gitui-org/gitui/blob/2fa693cb6ed431b21ebc300dd02e83c2476699ce/src/popups/branchlist.rs#L564-L600","documentation":"switch_to_selected_branch() first calls valid_selection() and bails when the current selection is not a usable branch entry - the list is empty, the index no longer points at a live entry after the branch list changed (deletion, fetch refresh), or the kind of entry selected cannot be switched to in this mode.","triggerScenarios":"Pressing enter in the branch popup with nothing highlighted (fresh popup, all entries filtered out by the search); the selected branch deleted by another git process while the popup was open; selection index out of range after the list rebuilt.","commonSituations":"Stale popup after running git branch -D in another terminal; typing a filter that empties the list and hitting enter anyway; races between fetch-driven list updates and keypresses.","solutions":["Close and reopen the branch popup so the list rebuilds, then select an entry.","Refresh repo state (fetch / press r) so deletions and new branches are reflected before switching.","Clear the filter and confirm an entry is actually highlighted before pressing enter."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// mirror the component's own guard before acting\nif !branches.is_empty() && (selection as usize) < branches.len() && branch_kind_switchable(selection) {\n    popup.switch_to_selected_branch()?;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-derive selection bounds after any list-mutating event (fetch, delete, filter change).","Reopen popups after performing out-of-band git operations in another terminal.","Bail verbosely instead of indexing when popup state may be stale."],"tags":["branch-popup","selection","stale-state","validation"],"backgroundTag":"invalid-selection","analyzedSha":"2fa693cb6ed431b21ebc300dd02e83c2476699ce","analyzedAt":"2026-08-16T23:07:36.562Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}