{"record":{"id":"dbc030b4ab26bb8b","repo":"gitbutlerapp/gitbutler","slug":"no-commit-ids-provided-for-discard-dbc030","errorCode":null,"errorMessage":"no commit IDs provided for discard","messagePattern":"no commit IDs provided for discard","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/commit/discard_commit.rs","lineNumber":38,"sourceCode":"    let mut count = 0usize;\n    for commit_id in subject_commits {\n        if !seen.insert(commit_id) {\n            continue;\n        }\n        count += 1;\n        let (selector, _commit) = editor.find_selectable_commit(commit_id)?;\n\n        let delimiter = SegmentDelimiter {\n            child: selector,\n            parent: selector,\n        };\n\n        editor.disconnect_segment_from(delimiter, SelectorSet::All, SelectorSet::All, false)?;\n        editor.replace(selector, Step::None)?;\n    }\n\n    if count == 0 {\n        bail!(\"no commit IDs provided for discard\");\n    }\n\n    editor.rebase()\n}\n","sourceCodeStart":20,"sourceCodeEnd":43,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/commit/discard_commit.rs#L20-L43","documentation":"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.","triggerScenarios":"Calling WorkspaceEditor::discard_commits with an empty iterator of commit IDs/selectors (or a list where every entry was skipped/already absent).","commonSituations":"Scripts that collect commit IDs from a filtered UI selection which came back empty; callers passing an uninitialized/default Vec.","solutions":["Check the ID list is non-empty before calling discard_commits","Return early in the caller with a no-op when the selection is empty","If IDs may be stale, resolve them to selectors first and only call discard when at least one resolves"],"exampleFix":"// before\neditor.discard_commits(ids, context)?; // ids may be empty\n// after\nif ids.is_empty() {\n    return Ok(()); // nothing selected\n}\neditor.discard_commits(ids, context)?;","handlingStrategy":"validation","validationCode":"if commit_ids.is_empty() {\n    return Ok(()); // or surface 'no selection' to the user\n}\neditor.discard_commits(commit_ids, context)?;","typeGuard":"fn has_selection(ids: &[gix::ObjectId]) -> bool { !ids.is_empty() }","tryCatchPattern":"match editor.discard_commits(ids, ctx) {\n    Err(e) if e.to_string().contains(\"no commit IDs provided\") => Ok(()),\n    other => other,\n}","preventionTips":["Guard against empty selections at the UI layer","Resolve and filter IDs before calling discard","Treat empty input as a no-op rather than an API call"],"tags":["git","discard","empty-input","validation"],"backgroundTag":"missing-required-argument","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"}