gitbutlerapp/gitbutler · error

Invalid parent delimitation: requested parent is not a…

Error message

Invalid parent delimitation: requested parent is not a direct parent of target.parent

What it means

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.

Solutions

  1. Build the parents list from the target's actual direct parents (resolve available parents first)
  2. Use try-selectors to validate each parent belongs to target.parent before the call
  3. Re-fetch selectors after each graph mutation, since ids/selectors can become stale

Example fix

// before
let parents = vec![grandparent_selector];
editor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;
// after
let available: HashSet<_> = target.parent.parents();
let parents = requested_parents.into_iter().filter(|s| available.contains(&s.id)).collect();
editor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;
Defensive patterns

Strategy: validation

Validate before calling

fn parents_are_direct(target: &Selector, parents: &[Selector], available: &HashSet<gix::ObjectId>) -> bool {
    parents.iter().all(|p| available.contains(&p.id))
}

Try / catch

for s in &parents {
    if !available_parents.contains(&s.id) {
        anyhow::bail!("parent {} is not a direct parent of target", s.id);
    }
}
editor.disconnect_segment_from(target, SelectorSet::Some(parents), children)?;

Prevention

When it happens

Trigger: 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.

Common situations: Batch graph-edit scripts that cache selectors across mutations, or code assuming indirect ancestors can be disconnected in one call.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/5200bccda263bbd8. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-rebase/src/graph_rebase/mutate.rs:454

            .edges_directed(target_parent.id, Direction::Outgoing)
            .map(|e| (e.id(), e.weight().to_owned(), e.target()))
            .collect::<Vec<_>>();

        // All available parents
        let available_parents = outgoing_edges
            .iter()
            .map(|(_, _, edge_target)| *edge_target)
            .collect::<HashSet<_>>();
        let available_children = incoming_edges
            .iter()
            .map(|(_, _, edge_source)| *edge_source)
            .collect::<HashSet<_>>();

        // 1. Verify that all parents and children to disconnect are directly connected to the target segment.
        if let Some(parents_to_disconnect) = parents_to_disconnect.as_ref() {
            for selector in parents_to_disconnect {
                if !available_parents.contains(&selector.id) {
                    return Err(anyhow!(
                        "Invalid parent delimitation: requested parent is not a direct parent of target.parent"
                    ));
                }
            }
        }

        if let Some(children_to_disconnect) = children_to_disconnect.as_ref() {
            for selector in children_to_disconnect {
                if !available_children.contains(&selector.id) {
                    return Err(anyhow!(
                        "Invalid parent delimitation: requested child is not a direct parent of target.child"
                    ));
                }
            }
        }

        let parent_ids_to_disconnect = parents_to_disconnect
            .as_ref()

View on GitHub (pinned to 58e5313667)