gitbutlerapp/gitbutler · error

no commit IDs provided for discard

Error message

no commit IDs provided for discard

What it means

discard_commits was invoked with an empty set of commit IDs, so after processing there is nothing to rebase. The function counts the commits it actually discarded and bails when the count is zero rather than performing a pointless rebase.

Solutions

  1. Check the ID list is non-empty before calling discard_commits
  2. Return early in the caller with a no-op when the selection is empty
  3. If IDs may be stale, resolve them to selectors first and only call discard when at least one resolves

Example fix

// before
editor.discard_commits(ids, context)?; // ids may be empty
// after
if ids.is_empty() {
    return Ok(()); // nothing selected
}
editor.discard_commits(ids, context)?;
Defensive patterns

Strategy: validation

Validate before calling

if commit_ids.is_empty() {
    return Ok(()); // or surface 'no selection' to the user
}
editor.discard_commits(commit_ids, context)?;

Type guard

fn has_selection(ids: &[gix::ObjectId]) -> bool { !ids.is_empty() }

Try / catch

match editor.discard_commits(ids, ctx) {
    Err(e) if e.to_string().contains("no commit IDs provided") => Ok(()),
    other => other,
}

Prevention

When it happens

Trigger: Calling WorkspaceEditor::discard_commits with an empty iterator of commit IDs/selectors (or a list where every entry was skipped/already absent).

Common situations: Scripts that collect commit IDs from a filtered UI selection which came back empty; callers passing an uninitialized/default Vec.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-workspace/src/commit/discard_commit.rs:38

    let mut count = 0usize;
    for commit_id in subject_commits {
        if !seen.insert(commit_id) {
            continue;
        }
        count += 1;
        let (selector, _commit) = editor.find_selectable_commit(commit_id)?;

        let delimiter = SegmentDelimiter {
            child: selector,
            parent: selector,
        };

        editor.disconnect_segment_from(delimiter, SelectorSet::All, SelectorSet::All, false)?;
        editor.replace(selector, Step::None)?;
    }

    if count == 0 {
        bail!("no commit IDs provided for discard");
    }

    editor.rebase()
}

View on GitHub (pinned to 58e5313667)