{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/api.rs","lineNumber":85,"sourceCode":"    fn stack_matches(stack: &but_graph::workspace::Stack, name: &str) -> bool {\n        stack.segments.iter().any(|segment| {\n            segment.ref_name().is_some_and(|ref_name| {\n                ref_name == name || 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":67,"sourceCodeEnd":92,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-debug/src/command/api.rs#L67-L92","documentation":"resolve_stack_id in the debug API could not match the user-supplied stack identifier against any stack in the current workspace. The identifier is matched by stack UUID or by workspace branch name; when the filter-map yields no matching stack id, the function bails with this message.","triggerScenarios":"Calling resolve_stack_id (e.g. via unapply_stack) with a `stack` argument that is neither a valid stack UUID present in workspace.stacks nor the name of a workspace branch of any stack in the workspace.","commonSituations":"Typo in the stack name or UUID, the stack was already unapplied/archived so it no longer appears in workspace.stacks, or the user passed a full branch ref name (e.g. refs/heads/foo) instead of the short branch name.","solutions":["List the current workspace stacks (e.g. `but debug workspace` equivalent) and copy the exact UUID or branch name","Retry with the short workspace branch name instead of a full ref or a local-only nickname","Verify the stack is still applied; if it was unapplied or archived, it will not resolve","If the stack exists in another worktree/workspace, switch to the workspace that contains it"],"exampleFix":"// before\nlet id = api.resolve_stack_id(&mut ws, \"my-branch\")?; // typo: branch is \"my_branch\"\n// after\nlet id = api.resolve_stack_id(&mut ws, \"my_branch\")?; // exact UUID or workspace branch name","handlingStrategy":"validation","validationCode":"let known: Vec<_> = workspace.stacks.iter()\n    .filter_map(|s| s.id.as_ref().map(|i| i.to_string()))\n    .chain(workspace.stacks.iter().filter_map(|s| s.branch_name()))\n    .collect();\nif !known.iter().any(|k| k == stack) { eprintln!(\"unknown stack: {stack}\"); }","typeGuard":null,"tryCatchPattern":"match api.resolve_stack_id(&mut ws, stack) {\n    Err(e) if e.to_string().contains(\"Could not resolve stack\") => eprintln!(\"use `but debug workspace` to list valid stack ids\"),\n    other => other?,\n}","preventionTips":["Copy stack UUIDs from workspace listings instead of typing them","Use exact short branch names, not full refs","Re-list stacks after unapply/archive operations before referencing them"],"tags":["cli","debug","stack","not-found"],"backgroundTag":"entity-not-found","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"}