{"record":{"id":"1679198422a472e6","repo":"gitbutlerapp/gitbutler","slug":"expected-selector-to-point-to-a-reference","errorCode":null,"errorMessage":"Expected selector to point to a reference","messagePattern":"Expected selector to point to a reference","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/graph_rebase/mod.rs","lineNumber":560,"sourceCode":"\n/// Provides lookup for different steps that a selector might point to.\npub trait LookupStep {\n    /// Look up the step that a given selector corresponds to.\n    fn lookup_step(&self, selector: Selector) -> Result<Step>;\n\n    /// Look up the step a given selector and assert it's a pick.\n    fn lookup_pick(&self, selector: Selector) -> Result<gix::ObjectId> {\n        match self.lookup_step(selector)? {\n            Step::Pick(Pick { id, .. }) => Ok(id),\n            _ => bail!(\"Expected selector to point to a pick\"),\n        }\n    }\n\n    /// Look up the step a given selector and assert it's a pick.\n    fn lookup_reference(&self, selector: Selector) -> Result<gix::refs::FullName> {\n        match self.lookup_step(selector)? {\n            Step::Reference { refname, .. } => Ok(refname),\n            _ => bail!(\"Expected selector to point to a reference\"),\n        }\n    }\n}\n\nimpl<M: RefMetadata> LookupStep for Editor<'_, '_, M> {\n    fn lookup_step(&self, selector: Selector) -> Result<Step> {\n        lookup_step(&self.graph, &self.history, selector)\n    }\n}\n\nimpl<M: RefMetadata> LookupStep for SuccessfulRebase<'_, '_, M> {\n    fn lookup_step(&self, selector: Selector) -> Result<Step> {\n        lookup_step(&self.graph, &self.history, selector)\n    }\n}\n\nimpl<M: RefMetadata> LookupStep for MaterializeOutcome<'_, '_, M> {\n    fn lookup_step(&self, selector: Selector) -> Result<Step> {","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/graph_rebase/mod.rs#L542-L578","documentation":"LookupStep::lookup_reference resolves a Selector and asserts the step is a Step::Reference, returning the ref's FullName. If the selector resolves to any other step (e.g. a commit Pick), the request is invalid and the library bails.","triggerScenarios":"Calling lookup_reference with a selector that resolves to a Pick (commit) or other non-Reference step — e.g. asking for the branch name of a commit selector, or a stale selector after graph mutation.","commonSituations":"Renaming/moving branches while accidentally passing commit selectors; selectors invalidated by prior move/drop operations shifting node identities.","solutions":["Inspect editor.lookup_step(selector) to confirm it is Step::Reference first","Use lookup_pick when the selector targets a commit","Obtain a fresh selector for the reference from the current editor"],"exampleFix":"// before\nlet refname = editor.lookup_reference(selector)?; // selector is a commit\n// after\nlet refname = match editor.lookup_step(selector)? {\n    Step::Reference { refname, .. } => refname,\n    Step::Pick(_) => bail!(\"expected a reference selector\"),\n    _ => bail!(\"unsupported step\"),\n};","handlingStrategy":"type-guard","validationCode":"match editor.lookup_step(selector)? { Step::Reference { .. } => {}, _ => bail!(\"not a reference\") }","typeGuard":"fn is_reference_step(editor: &Editor<impl RefMetadata>, s: Selector) -> bool {\n    matches!(editor.lookup_step(s), Ok(Step::Reference { .. }))\n}","tryCatchPattern":"match editor.lookup_reference(selector) {\n    Ok(refname) => refname,\n    Err(_) => bail!(\"selector does not point at a reference\"),\n}","preventionTips":["Call lookup_step first when selector origin is unclear","Use distinct variables for commit vs reference selectors"],"tags":["rebase","selector","type-mismatch"],"backgroundTag":"type-mismatch","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"}