{"record":{"id":"02d979e3ad9071d2","repo":"gitbutlerapp/gitbutler","slug":"reference-step-must-have-a-non-empty-virtual-branc","errorCode":null,"errorMessage":"Reference step must have a non-empty virtual branch name","messagePattern":"Reference step must have a non-empty virtual branch name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/lib.rs","lineNumber":196,"sourceCode":"        match step {\n            RebaseStep::Pick { commit_id, .. } => {\n                self.assure_unique_step_and_existing_non_base(commit_id, \"Picked\")?;\n            }\n            RebaseStep::SquashIntoPreceding {\n                commit_id,\n                new_message: _,\n            } => {\n                self.assure_unique_step_and_existing_non_base(commit_id, \"Fixup\")?;\n                if matches!(self.steps.last(), Some(RebaseStep::Reference { .. })) {\n                    bail!(\"Fixup commit must not come after a reference step\");\n                }\n                if self.steps.is_empty() {\n                    bail!(\"Fixup must have a commit to work on\");\n                }\n            }\n            RebaseStep::Reference(name) => {\n                if matches!(name, but_core::Reference::Virtual(name) if name.is_empty()) {\n                    return Err(anyhow!(\n                        \"Reference step must have a non-empty virtual branch name\"\n                    ));\n                }\n            }\n        }\n        Ok(())\n    }\n\n    fn assure_unique_step_and_existing_non_base(\n        &self,\n        commit_id: &gix::oid,\n        kind: &str,\n    ) -> Result<()> {\n        self.repo.find_commit(commit_id)?;\n        if Some(commit_id) == self.base.as_deref() {\n            bail!(\"{kind} commit cannot be the base commit\");\n        }\n        if self.steps.iter().any(|s| s.commit_id() == Some(commit_id)) {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/lib.rs#L178-L214","documentation":"RebaseStep::validate_step checks each rebase step before execution. A Reference step naming a virtual branch with an empty name is invalid because the reference must identify a real branch; empty names would create ambiguous or unaddressable references during the rebase.","triggerScenarios":"Pushing RebaseStep::Reference(but_core::Reference::Virtual(String::new())) (or an empty virtual branch name sourced from user input or config) into the builder before calling rebase().","commonSituations":"UI/CLI layers passing an unvalidated branch-name field straight through, or deserialized steps from JSON where the name field was an empty string.","solutions":["Reject empty virtual branch names at the input boundary before building the step","Trim user input and require a non-empty name when creating RebaseStep::Reference","Validate all steps (validate_step) and surface the error before mutating the graph"],"exampleFix":"// before\nsteps.push(RebaseStep::Reference(Reference::Virtual(name))); // name = \"\"\n// after\nanyhow::ensure!(!name.trim().is_empty(), \"virtual branch name must not be empty\");\nsteps.push(RebaseStep::Reference(Reference::Virtual(name.trim().to_owned())));","handlingStrategy":"validation","validationCode":"fn valid_reference_step(step: &RebaseStep) -> bool {\n    !matches!(step, RebaseStep::Reference(but_core::Reference::Virtual(n)) if n.trim().is_empty())\n}","typeGuard":"fn non_empty_virtual(name: &str) -> Option<but_core::Reference> {\n    (!name.trim().is_empty()).then(|| but_core::Reference::Virtual(name.trim().to_owned()))\n}","tryCatchPattern":"if let Err(e) = editor.validate_step(&step) {\n    anyhow::bail!(\"rejecting invalid rebase step: {e}\");\n}","preventionTips":["Trim and require non-empty branch names at every input boundary","Validate all RebaseSteps before mutating the graph","Reject empty-string branch names in deserialization (custom Deserialize or serde try_from)"],"tags":["rebase","validation","empty-string"],"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"}