{"record":{"id":"c3436c43ae16119e","repo":"gitbutlerapp/gitbutler","slug":"could-not-resolve-stack-stack-by-uuid-or-works","errorCode":null,"errorMessage":"Could not resolve stack '{stack}' by UUID or workspace branch name","messagePattern":"Could not resolve stack '(.+?)' by UUID or workspace branch name","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/api.rs","lineNumber":86,"sourceCode":"        stack.segments.iter().any(|segment| {\n            segment.ref_name().is_some_and(|ref_name| {\n                ref_name.as_bstr() == name.as_bytes()\n                    || ref_name.shorten().as_bstr() == name.as_bytes()\n            })\n        })\n    }\n    if let Ok(stack_id) = stack.parse::<StackId>() {\n        return Ok(stack_id);\n    }\n\n    let (_guard, _repo, workspace, _db) = ctx.workspace_and_db()?;\n    let mut matches = workspace.stacks.iter().filter_map(|workspace_stack| {\n        stack_matches(workspace_stack, stack)\n            .then_some(workspace_stack.id)\n            .flatten()\n    });\n    let Some(stack_id) = matches.next() else {\n        bail!(\"Could not resolve stack '{stack}' by UUID or workspace branch name\");\n    };\n    if matches.next().is_some() {\n        bail!(\"Stack name '{stack}' is ambiguous in the current workspace\");\n    }\n    Ok(stack_id)\n}\n","sourceCodeStart":68,"sourceCodeEnd":93,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-debug/src/command/api.rs#L68-L93","documentation":"`resolve_stack_id()` in the `but api unapply-stack` debug command accepts either a stack UUID (parsed as `StackId`) or a workspace branch name matched against each stack segment's ref name (full or shortened). If the argument parses as neither a UUID nor any stack's branch name, it bails. Note the UUID attempt is tried first, so any argument that fails both lookups lands here.","triggerScenarios":"Running `but api unapply-stack <name>` where `<name>` is not a valid StackId and no workspace stack has a segment ref equal (or shortenable) to it — typo, branch not in the workspace, or stack already deleted.","commonSituations":"Typos in branch names; referring to a plain git branch that was never imported as a stack; stack renamed or removed since it was listed; UUID copied with a stray character.","solutions":["List the workspace's stacks and their exact branch names first (e.g. `but api branch-list`) and copy the exact ref or id.","Use the full ref (`refs/heads/<branch>`) if the short name doesn't match.","Prefer the stack UUID, which is unambiguous and skips name matching entirely.","Confirm you're in the right workspace/project — stacks from another project will never match."],"exampleFix":"# before\nbut api unapply-stack feautre-x     # typo\n\n# after\nbut api branch-list                  # find exact name/id\nbut api unapply-stack feature-x       # or the stack UUID","handlingStrategy":"validation","validationCode":"# Shell — resolve the stack id before running the command\nbut api branch-list > /tmp/stacks.txt\ngrep -F \"<name>\" /tmp/stacks.txt || { echo \"no such stack\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Script against stack UUIDs, not branch names — UUIDs never depend on workspace content.","Run `but api branch-list` first and copy exact ref names or ids.","Remember matching accepts both full and shortened ref names; prefer the full `refs/heads/<branch>` form."],"tags":["stack","cli","identifier-resolution","debug-command"],"backgroundTag":"stack-not-found","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}