{"record":{"id":"66fca2fb0a546164","repo":"gitbutlerapp/gitbutler","slug":"integration-steps-cannot-be-empty","errorCode":null,"errorMessage":"Integration steps cannot be empty","messagePattern":"Integration steps cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/integrate_branch_upstream/mod.rs","lineNumber":124,"sourceCode":"    pub divergence: IntegrationDivergenceDisplay,\n}\n\n/// Integrate the upstream changes in the order of the provided steps.\n///\n/// `ref_name` - The full reference name of the local branch we're integrating the upstream changes into.\n///\n/// `steps` - The vector of steps in the application order (parent to child) that describe the actions to perform\n///   for the integration of the changes.\npub fn integrate_branch_with_steps<'ws, 'meta, M: RefMetadata>(\n    ref_name: &gix::refs::FullNameRef,\n    integration: InteractiveIntegration,\n    workspace: &'ws mut but_graph::Workspace,\n    meta: &'meta mut M,\n    repo: &gix::Repository,\n    db: &'meta mut but_db::DbHandle,\n) -> Result<SuccessfulRebase<'ws, 'meta, M>> {\n    if integration.steps.is_empty() {\n        bail!(\"Integration steps cannot be empty\")\n    }\n    // The editor maps every segment in the graph, including the remote\n    // reference of the branch we're integrating.\n    let mut editor = Editor::create(workspace, meta, repo, db)?;\n    // Step 1: We prepare the steps before building.\n    // At this point, we construct the commits for the squash steps in memory.\n    let prepared_steps = prepare_integration_steps_for_editor(&editor, &integration.steps)?;\n\n    let delimiter_child = editor.select_reference(ref_name)?;\n    let delimiter_parent = match integration.first_local_not_integrated {\n        Some(commit_id) => {\n            let selector = find_local_commit_until_merge_base(\n                ref_name,\n                commit_id,\n                integration.merge_base,\n                &editor,\n            )?;\n            let Some(selector) = selector else {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/integrate_branch_upstream/mod.rs#L106-L142","documentation":"`integrate_branch_with_steps` performs upstream integration driven by an ordered list of integration steps (squash/pick operations). An empty step list means there is nothing to integrate, which the function treats as a programming error in the caller rather than a no-op.","triggerScenarios":"Calling `integrate_branch_with_steps` with an `Integration` whose `steps` vector is empty — e.g. the caller computed steps from a diff that produced no operations.","commonSituations":"Calling integration on a branch with no upstream commits to integrate; a caller bug that skips step computation; filtering that removed all steps without short-circuiting.","solutions":["Check `integration.steps.is_empty()` before calling and return early / skip integration","Ensure step computation actually yields steps for the branch's upstream divergence","Only invoke integration when the branch actually diverged from upstream"],"exampleFix":"// before\nintegrate_branch_with_steps(workspace, meta, repo, db, integration)?;\n// after\nif integration.steps.is_empty() {\n    return Ok(None); // nothing to integrate\n}\nintegrate_branch_with_steps(workspace, meta, repo, db, integration)?;","handlingStrategy":"validation","validationCode":"if integration.steps.is_empty() {\n    return Ok(None); // nothing to integrate\n}","typeGuard":null,"tryCatchPattern":"match integrate_branch_with_steps(...) {\n    Err(e) if e.to_string().contains(\"steps cannot be empty\") => return Ok(None),\n    Err(e) => return Err(e.into()),\n    Ok(r) => r,\n}","preventionTips":["Short-circuit integration when no upstream divergence exists","Assert step computation produces non-empty steps before calling","Only call integration for branches known to be behind upstream"],"tags":["git","integration","validation"],"backgroundTag":"empty-required-field","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"}