{"record":{"id":"32ec16077a2b6f8d","repo":"gitbutlerapp/gitbutler","slug":"expected-selector-to-point-to-a-pick","errorCode":null,"errorMessage":"Expected selector to point to a pick","messagePattern":"Expected selector to point to a pick","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/graph_rebase/mod.rs","lineNumber":552,"sourceCode":"    pub meta: &'meta mut M,\n    /// The database handle the editor was created with.\n    pub db: &'meta mut but_db::DbHandle,\n    /// True if a conflict occurred during checkout. This is always false if\n    /// `allow_uncommitted_changes_to_conflict_with_new_head` in the options\n    /// struct passed to the materialize call is false.\n    pub checkout_conflict_occurred: bool,\n}\n\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","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/graph_rebase/mod.rs#L534-L570","documentation":"LookupStep::lookup_pick resolves a Selector to its graph step and asserts it is a Step::Pick, returning the commit id. Any other step kind (e.g. a Reference) makes the request invalid, so the library bails instead of returning a wrong id.","triggerScenarios":"Calling lookup_pick with a selector that normalizes to a non-Pick step — a reference/branch selector, or a stale selector whose id now points elsewhere in the editor graph.","commonSituations":"Scripting squash/reword operations with a selector captured for a branch; selector indices shifted after graph mutations (moves, drops) so lookups resolve to different nodes.","solutions":["Check the step kind via lookup_step before calling lookup_pick","Use lookup_reference for reference selectors","Re-create/re-normalize the selector against the current editor state"],"exampleFix":"// before\nlet id = editor.lookup_pick(selector)?; // selector is a reference\n// after\nlet id = match editor.lookup_step(selector)? {\n    Step::Pick(pick) => pick.id,\n    Step::Reference { .. } => bail!(\"expected a commit selector\"),\n    _ => bail!(\"unsupported step\"),\n};","handlingStrategy":"type-guard","validationCode":"match editor.lookup_step(selector)? { Step::Pick(_) => {}, _ => bail!(\"not a pick\") }","typeGuard":"fn is_pick_step(editor: &Editor<impl RefMetadata>, s: Selector) -> bool {\n    matches!(editor.lookup_step(s), Ok(Step::Pick(_)))\n}","tryCatchPattern":"match editor.lookup_pick(selector) {\n    Ok(id) => id,\n    Err(_) => bail!(\"selector does not point at a commit pick\"),\n}","preventionTips":["Call lookup_step first when selector origin is unclear","Refresh selectors after graph edits"],"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"}