{"record":{"id":"5200bccda263bbd8","repo":"gitbutlerapp/gitbutler","slug":"invalid-parent-delimitation-requested-parent-is-n","errorCode":null,"errorMessage":"Invalid parent delimitation: requested parent is not a direct parent of target.parent","messagePattern":"Invalid parent delimitation: requested parent is not a direct parent of target\\.parent","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/graph_rebase/mutate.rs","lineNumber":454,"sourceCode":"            .edges_directed(target_parent.id, Direction::Outgoing)\n            .map(|e| (e.id(), e.weight().to_owned(), e.target()))\n            .collect::<Vec<_>>();\n\n        // All available parents\n        let available_parents = outgoing_edges\n            .iter()\n            .map(|(_, _, edge_target)| *edge_target)\n            .collect::<HashSet<_>>();\n        let available_children = incoming_edges\n            .iter()\n            .map(|(_, _, edge_source)| *edge_source)\n            .collect::<HashSet<_>>();\n\n        // 1. Verify that all parents and children to disconnect are directly connected to the target segment.\n        if let Some(parents_to_disconnect) = parents_to_disconnect.as_ref() {\n            for selector in parents_to_disconnect {\n                if !available_parents.contains(&selector.id) {\n                    return Err(anyhow!(\n                        \"Invalid parent delimitation: requested parent is not a direct parent of target.parent\"\n                    ));\n                }\n            }\n        }\n\n        if let Some(children_to_disconnect) = children_to_disconnect.as_ref() {\n            for selector in children_to_disconnect {\n                if !available_children.contains(&selector.id) {\n                    return Err(anyhow!(\n                        \"Invalid parent delimitation: requested child is not a direct parent of target.child\"\n                    ));\n                }\n            }\n        }\n\n        let parent_ids_to_disconnect = parents_to_disconnect\n            .as_ref()","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/graph_rebase/mutate.rs#L436-L472","documentation":"Before disconnecting, disconnect_segment_from validates that every requested parent selector is a direct parent of the target segment (target.parent). This error is thrown when one of the supplied parent selectors refers to a commit that is not directly connected to the target's parent, which would corrupt the graph edit.","triggerScenarios":"Calling disconnect_segment_from with parents_to_disconnect containing a Selector whose id is not among the target's direct parent commits — e.g. a grandparent, a commit on a different line of history, or a stale selector after prior mutations.","commonSituations":"Batch graph-edit scripts that cache selectors across mutations, or code assuming indirect ancestors can be disconnected in one call.","solutions":["Build the parents list from the target's actual direct parents (resolve available parents first)","Use try-selectors to validate each parent belongs to target.parent before the call","Re-fetch selectors after each graph mutation, since ids/selectors can become stale"],"exampleFix":"// before\nlet parents = vec![grandparent_selector];\neditor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;\n// after\nlet available: HashSet<_> = target.parent.parents();\nlet parents = requested_parents.into_iter().filter(|s| available.contains(&s.id)).collect();\neditor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;","handlingStrategy":"validation","validationCode":"fn parents_are_direct(target: &Selector, parents: &[Selector], available: &HashSet<gix::ObjectId>) -> bool {\n    parents.iter().all(|p| available.contains(&p.id))\n}","typeGuard":null,"tryCatchPattern":"for s in &parents {\n    if !available_parents.contains(&s.id) {\n        anyhow::bail!(\"parent {} is not a direct parent of target\", s.id);\n    }\n}\neditor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;","preventionTips":["Derive parent selectors from the target's own parent list","Discard and re-resolve selectors after each graph mutation","Treat the disconnect operation as strictly one-hop: handle ancestors iteratively"],"tags":["rebase","validation","graph"],"backgroundTag":"invalid-argument-value","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"}