gitbutlerapp/gitbutler · error

the prefix is unambiguous

Error message

the prefix is unambiguous

What it means

A panic (expect) in but-debug's graph command: lookup_prefix() found multiple objects matching the --limit-extension hex prefix (it returns a Candidates mode), and the debug path asserts exactly one. Standard git abbreviated-hash ambiguity, turned into a hard abort.

Source

Thrown at crates/but-debug/src/command/graph.rs:69

        .transpose()?
        .map(|id| id.detach());
    let opts = but_graph::init::Options {
        extra_target_commit_id: extra_target,
        collect_tags: true,
        hard_limit: graph_args.hard_limit,
        commits_limit_hint: graph_args.limit.flatten(),
        commits_limit_recharge_location: graph_args
            .limit_extension
            .iter()
            .map(|short_hash| {
                repo.objects
                    .lookup_prefix(
                        gix::hash::Prefix::from_hex(short_hash).expect("valid hex prefix"),
                        None,
                    )
                    .unwrap()
                    .expect("object for prefix exists")
                    .expect("the prefix is unambiguous")
            })
            .collect(),
        dangerously_skip_postprocessing_for_debugging: graph_args.no_post,
        worktrees: false,
    };

    let graph = match graph_args.ref_name.as_deref() {
        None => but_graph::Graph::from_head(
            &repo,
            &meta,
            but_core::ref_metadata::ProjectMeta::default(),
            &mut setup::debug_db()?,
            opts,
        ),
        Some(ref_name) => {
            let mut reference = repo.find_reference(ref_name)?;
            let id = reference.peel_to_id()?;
            but_graph::Graph::from_commit_traversal(

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Lengthen the prefix until it is unique — `git rev-parse <prefix>` tells you when it is still ambiguous.
  2. Or pass the full 40/64-char hash.
  3. Update scripts that truncate hashes to instead use git's own disambiguation output.

Example fix

# before
but debug graph --limit-extension 4c1f  # ambiguous in this repo

# after
but debug graph --limit-extension $(git rev-parse --short=12 <ref>)
Defensive patterns

Strategy: validation

Validate before calling

# let git pick a unambiguous short hash
EXT=$(git rev-parse --short=12 "$REF") # errors out itself if still ambiguous
but debug graph --limit-extension "$EXT"

Prevention

When it happens

Trigger: Passing a short --limit-extension prefix (e.g. 4-6 hex chars) that is shared by two or more objects in this repository; larger repositories make short prefixes collide more often.

Common situations: Using copied short hashes after the repo gained new objects that collide; scripts that cut hashes to a fixed short length; repositories with many tags/blobs sharing early nibbles.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/68377aaae4e2b6b8. Report an issue: GitHub.