{"record":{"id":"5094da5a71edeba7","repo":"gitbutlerapp/gitbutler","slug":"this-metadata-backend-doesn-t-support-branch-stack","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":261,"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":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-core/src/lib.rs#L243-L279","documentation":"Default implementation of WorkspaceMetadata::set_branch_stack_order: backends that cannot persist the ordered refs of an ad-hoc/single-branch stack deliberately fail with this message instead of silently dropping the order. The trait ships a capability probe, can_persist_branch_stack_order() (default false), so callers can avoid the failure entirely. Hitting it means set was called on a backend that never overrode the default.","triggerScenarios":"Calling set_branch_stack_order on any backend that keeps the default — lightweight, in-memory, or test backends — without first checking can_persist_branch_stack_order().","commonSituations":"Custom or embedded but_core metadata backends implementing only the required methods; test doubles; new call sites written against the full workspace backend and reused against a simpler one.","solutions":["Guard the call: if meta.can_persist_branch_stack_order() { meta.set_branch_stack_order(&branches)?; } and otherwise keep the order in memory only.","Switch to the metadata backend that persists stack order (the standard workspace backend).","If you own the backend, implement set_branch_stack_order and return true from can_persist_branch_stack_order."],"exampleFix":"// before\nmeta.set_branch_stack_order(&branches)?;\n\n// after\nif meta.can_persist_branch_stack_order() {\n    meta.set_branch_stack_order(&branches)?;\n} else {\n    // session-only fallback: keep the order without persisting\n    session_order = Some(branches.to_vec());\n}","handlingStrategy":"validation","validationCode":"if meta.can_persist_branch_stack_order() {\n    meta.set_branch_stack_order(&branches)?;\n} // else: keep order in memory only","typeGuard":"fn can_persist_order(meta: &dyn WorkspaceMetadata) -> bool {\n    meta.can_persist_branch_stack_order()\n}","tryCatchPattern":"match meta.set_branch_stack_order(&branches) {\n    Err(err) if err.to_string().contains(\"doesn't support branch stack order\") => {\n        // expected on lightweight backends: degrade silently\n    }\n    r => r?,\n}","preventionTips":["Always pair set_branch_stack_order with the can_persist_branch_stack_order probe.","Document capability defaults when implementing the trait.","In tests, either implement persistence or deliberately assert this error."],"tags":["trait","capability","metadata","backend","branch-stack"],"backgroundTag":"unsupported-backend-capability","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}