{"record":{"id":"5094da5a71edeba7","repo":"gitbutlerapp/gitbutler","slug":"this-metadata-backend-doesn-t-support-branch-stack-order","errorCode":null,"errorMessage":"This metadata backend doesn't support branch stack order","messagePattern":"This metadata backend doesn't support branch stack order","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-core/src/lib.rs","lineNumber":262,"sourceCode":"    /// Implementations that don't persist branch stack order can return `Ok(None)`.\n    ///\n    /// This is best-effort: the returned refs may include entries for branches that no longer\n    /// exist if pruning hasn't run since they were deleted (see\n    /// [`Self::remove_missing_branch_stack_order_references`]). Callers must treat the result as a\n    /// hint and validate each ref against the repository, ignoring any that don't resolve, rather\n    /// than assuming every entry is live.\n    fn branch_stack_order(\n        &self,\n        _ref_name: &gix::refs::FullNameRef,\n    ) -> anyhow::Result<Option<Vec<gix::refs::FullName>>> {\n        Ok(None)\n    }\n\n    /// Persist the ordered local branch refs for an ad-hoc/single-branch stack, from tip to base.\n    ///\n    /// Implementations that don't persist branch stack order should return an error.\n    fn set_branch_stack_order(&mut self, _branches: &[gix::refs::FullName]) -> anyhow::Result<()> {\n        anyhow::bail!(\"This metadata backend doesn't support branch stack order\")\n    }\n\n    /// Return `true` if this backend can persist ad-hoc/single-branch stack order.\n    fn can_persist_branch_stack_order(&self) -> bool {\n        false\n    }\n\n    /// Rename a local branch ref in persisted ad-hoc/single-branch stack order metadata.\n    ///\n    /// Implementations that don't persist branch stack order can ignore this.\n    fn rename_branch_stack_order_reference(\n        &mut self,\n        _old_ref_name: &gix::refs::FullNameRef,\n        _new_ref_name: &gix::refs::FullNameRef,\n    ) -> anyhow::Result<()> {\n        Ok(())\n    }\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-core/src/lib.rs#L244-L280","documentation":"This error is the default trait-method implementation for MetadataBackend::set_branch_stack_order. Backends that cannot persist the ordered local branch refs of an ad-hoc/single-branch stack (tip to base) inherit this bail. Callers must check can_persist_branch_stack_order() first.","triggerScenarios":"Calling set_branch_stack_order on a metadata backend whose can_persist_branch_stack_order() returns false (e.g. a backend that only stores workspace state without branch-order persistence).","commonSituations":"Persisting the order of an ad-hoc or single-branch stack with a metadata backend that does not support branch ordering; forgetting to consult can_persist_branch_stack_order() before writing order.","solutions":["Check backend.can_persist_branch_stack_order() before calling set_branch_stack_order and skip persistence when false","Use a metadata backend implementation that overrides set_branch_stack_order with real persistence","Keep the branch order in memory or in a separate store when the backend cannot persist it"],"exampleFix":"// before\nbackend.set_branch_stack_order(&branches)?;\n// after\nif backend.can_persist_branch_stack_order() {\n    backend.set_branch_stack_order(&branches)?;\n}","handlingStrategy":"validation","validationCode":"if backend.can_persist_branch_stack_order() {\n    backend.set_branch_stack_order(&branches)?;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always gate order persistence behind can_persist_branch_stack_order()","Read the trait-method docs: default impls bail by design","Keep a memory fallback when the backend cannot persist"],"tags":["rust","metadata","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}