{"record":{"id":"079dcfc5c7071b42","repo":"gitbutlerapp/gitbutler","slug":"no-commit-ids-provided-for-uncommit","errorCode":null,"errorMessage":"no commit IDs provided for uncommit","messagePattern":"no commit IDs provided for uncommit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/commit/uncommit.rs","lineNumber":206,"sourceCode":"///\n/// The commits are removed from branch history, but their changes are\n/// **kept** — they surface as uncommitted workspace modifications. When\n/// `assign_to` is set, newly surfaced hunks are assigned to that stack.\n///\n/// This contrasts with [`super::discard_commit::commit_discard()`], which\n/// removes both the commit and its changes.\n///\n/// When `dry_run` is enabled, it returns a preview of the resulting workspace\n/// state without materializing the rewrite.\npub fn commit_uncommit_only_with_perm(\n    ctx: &mut but_ctx::Context,\n    subject_commit_ids: Vec<gix::ObjectId>,\n    assign_to: Option<but_core::ref_metadata::StackId>,\n    dry_run: DryRun,\n    perm: &mut RepoExclusive,\n) -> anyhow::Result<UncommitResult> {\n    if subject_commit_ids.is_empty() {\n        anyhow::bail!(\"no commit IDs provided for uncommit\");\n    }\n    let context_lines = ctx.settings.context_lines;\n    let mut meta = ctx.meta()?;\n    let (repo, mut ws, mut db) = ctx.workspace_mut_and_db_mut_with_perm(perm)?;\n\n    let surfaced =\n        SurfacedHunks::record_before(assign_to, dry_run, &mut db, &repo, &ws, context_lines)?;\n\n    let editor = Editor::create(&mut ws, &mut meta, &repo, &mut db)?;\n\n    let mut rebase =\n        but_workspace::commit::discard_commits(editor, subject_commit_ids.iter().copied())\n            .with_context(|| {\n                format!(\n                    \"failed to uncommit commits: {}\",\n                    subject_commit_ids\n                        .iter()\n                        .map(|id| id.to_hex().to_string())","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/commit/uncommit.rs#L188-L224","documentation":"Uncommitting extracts the changes of given commits back into the workspace; it requires at least one commit ID. `commit_uncommit_only_with_perm` validates the input list and bails immediately if empty, avoiding a no-op rebase of the stack.","triggerScenarios":"Calling `commit_uncommit_only` / `commit_uncommit_with_perm` with an empty `subject_commit_ids` vector, optionally with an `assign_to` stack ID but no commits.","commonSituations":"User invokes 'uncommit' from the UI with no commit selected; a script parses commit IDs from output that matched nothing; duplicated IDs collapse to an empty set upstream.","solutions":["Pass at least one commit ID in `subject_commit_ids`","Validate the selection before calling the API and show a user-facing message when empty","Check the code deriving commit IDs (parsing, filtering) to ensure it yields non-empty output"],"exampleFix":"// before\nuncommit(ctx, Vec::new(), assign_to, dry_run)?;\n// after\nensure!(!ids.is_empty(), \"No commits selected to uncommit\");\nuncommit(ctx, ids, assign_to, dry_run)?;","handlingStrategy":"validation","validationCode":"if ids.is_empty() { eprintln!(\"select a commit to uncommit\"); return Ok(()); }","typeGuard":null,"tryCatchPattern":"match api.commit_uncommit_only(ctx, ids, assign_to, dry_run) {\n    Err(e) if e.to_string().contains(\"no commit IDs provided for uncommit\") => prompt_selection(),\n    other => other?,\n}","preventionTips":["Require a selected commit in the UI before enabling the uncommit action","Validate parsed commit IDs are non-empty after any parsing/filtering step","Add unit tests covering empty-input rejection for command wrappers"],"tags":["validation","empty-input","uncommit"],"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"}