{"record":{"id":"51f78f86410c628b","repo":"gitbutlerapp/gitbutler","slug":"selected-edge-endpoint-wasn-t-found-among-direct-neighbors","errorCode":null,"errorMessage":"Selected edge endpoint wasn't found among direct neighbors","messagePattern":"Selected edge endpoint wasn't found among direct neighbors","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/graph_manipulation.rs","lineNumber":236,"sourceCode":"    edge_selection: EdgeSelection,\n) -> Result<Vec<(Selector, usize)>> {\n    let available = match edge_selection {\n        EdgeSelection::Children => editor.direct_children(target)?,\n        EdgeSelection::Parents => editor.direct_parents(target)?,\n    };\n\n    match selectors {\n        SelectorSet::All => Ok(available),\n        SelectorSet::None => Ok(Vec::new()),\n        SelectorSet::Some(some_selectors) => {\n            let mut selected = Vec::new();\n            for selector in some_selectors.as_slice() {\n                let selector = selector.to_selector(editor)?;\n                let Some((_, order)) = available\n                    .iter()\n                    .find(|(candidate, _)| *candidate == selector)\n                else {\n                    bail!(\"Selected edge endpoint wasn't found among direct neighbors\")\n                };\n                selected.push((selector, *order));\n            }\n            Ok(selected)\n        }\n    }\n}\n\n/// Reconnect a rebuilt segment to previously selected children and parents.\n///\n/// `editor` is the mutable graph editor whose edges will be recreated.\n///\n/// `delimiter` identifies the rebuilt segment's child-most and parent-most\n/// selectors.\n///\n/// `children` are the previously captured child edges that should point back to\n/// `delimiter.child`. If the child is already connected to `delimiter.child`, no\n/// new edge is added. Otherwise, the original edge order is reused when","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/graph_manipulation.rs#L218-L254","documentation":"When reordering/integrating branches, edge selectors must refer to endpoints that are direct neighbors in the current commit graph. If a selected selector is not found among the available neighbor candidates, the selection is invalid for the current graph state and the function bails.","triggerScenarios":"Calling integrate_branch_with_steps with edge selectors computed against an older graph topology (after commits were moved, rebased, or removed), so the selector's endpoint is no longer a direct neighbor.","commonSituations":"Stale UI selections after another operation reshaped the stack; concurrent modifications to the workspace between selection and integration; hardcoded/serialized selectors reused across sessions.","solutions":["Recompute the graph and derive fresh edge selectors immediately before calling integrate_branch_with_steps","Re-run the branch integration from the current workspace state rather than replaying cached steps","Check that the target branch/commit is still a direct neighbor of the intended anchor in the current stack"],"exampleFix":"// before\nlet steps = load_cached_steps(); // selectors from old graph\nintegrate_branch_with_steps(editor, steps)?;\n// after\nlet steps = compute_steps_from_current_graph(editor)?;\nintegrate_branch_with_steps(editor, steps)?;","handlingStrategy":"validation","validationCode":"let available = current_neighbor_edges(editor)?;\nif !steps.iter().all(|s| available.contains(&s.endpoint)) {\n    steps = recompute_steps(editor)?;\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"direct neighbors\") => {\n        // recompute selectors from the current graph and retry\n    }\n    other => other?,\n}","preventionTips":["Recompute edge selectors immediately before graph manipulation","Invalidate cached steps after any operation that rewrites history","Serialize the graph version alongside saved selectors and compare before use"],"tags":["git","graph","stale-state"],"backgroundTag":"resource-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}