{"record":{"id":"e2834edcaa28e60c","repo":"gitbutlerapp/gitbutler","slug":"no-branch-found-for-id-branch-id","errorCode":null,"errorMessage":"No branch found for ID: {branch_id}","messagePattern":"No branch found for ID: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/forge/review.rs","lineNumber":469,"sourceCode":"        }\n    }\n    Ok(branches_without_prs)\n}\n\nfn get_branch_names(project: &Project, branch_id: &str) -> anyhow::Result<Vec<String>> {\n    let ctx = Context::new_from_legacy_project(project.clone())?;\n    let id_map = IdMap::legacy_new_from_context(&ctx)?;\n    let branch_ids = id_map\n        .parse_using_context(branch_id, &ctx)?\n        .iter()\n        .filter_map(|clid| match clid {\n            CliId::Branch(branch) => Some(branch.name.clone()),\n            _ => None,\n        })\n        .collect::<Vec<_>>();\n\n    if branch_ids.is_empty() {\n        anyhow::bail!(\"No branch found for ID: {branch_id}\");\n    }\n\n    Ok(branch_ids)\n}\n\n#[expect(clippy::too_many_arguments)]\npub async fn handle_multiple_branches_in_workspace(\n    ctx: &mut Context,\n    review_map: &std::collections::HashMap<String, Vec<but_forge::ForgeReview>>,\n    applied_stacks: &[HeadInfoStack],\n    skip_force_push_protection: bool,\n    with_force: bool,\n    run_hooks: bool,\n    default_message: bool,\n    draft: bool,\n    message: Option<&ForgeReviewMessage>,\n    out: &mut OutputChannel,\n    selected_branches: Option<Vec<String>>,","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/forge/review.rs#L451-L487","documentation":"`get_branch_names` converts a user-supplied CliId into branch names but can only map IDs of the `CliId::Branch` variant. If every ID in the collection maps to something else (commit, file, workspace, etc.) or is empty, there is no branch behind the given `branch_id`, so it bails naming the ID. This is an ID-to-entity resolution failure in the review pipeline.","triggerScenarios":"Calling `create_review` with a CliId that does not refer to a branch — e.g. passing a commit or file ID — or the referenced stack entry resolved to zero branch IDs (deleted/merged branch, stale ID after a rebase).","commonSituations":"User passes an ID copied from an older `but status` output after the branch was rebased/deleted; passing a commit ID instead of a branch ID to `but review`; automation scripts using stale CliIds.","solutions":["Run `but status` to get current valid branch CliIds and use one that maps to a real branch","Pass the branch name directly instead of a CliId if the command supports it","Check that the branch still exists and hasn't been deleted or fully merged","Refresh IDs after any rebase, push, or stack operation before creating a review"],"exampleFix":"null","handlingStrategy":"type-guard","validationCode":"let branch_ids: Vec<_> = resolve_ids(ctx, &cli_id)?\n    .into_iter()\n    .filter(|id| matches!(id, CliId::Branch(_)))\n    .collect();\nif branch_ids.is_empty() {\n    bail!(\"{cli_id} is not a branch; run `but status` for a valid branch ID\");\n}","typeGuard":"fn is_branch_id(ids: &[CliId]) -> bool {\n    ids.iter().any(|id| matches!(id, CliId::Branch(_)))\n}","tryCatchPattern":"match create_review(..., cli_id, ...) {\n    Err(e) if e.to_string().starts_with(\"No branch found for ID\") => {\n        eprintln!(\"ID does not refer to a branch; refresh with `but status`\");\n    }\n    other => other?,\n}","preventionTips":["Always fetch fresh CliIds from `but status` right before use — never cache them across operations","Validate that the ID kind matches the expected entity (branch vs commit vs file) before passing it","Re-resolve IDs after any rebase, push, or stack mutation"],"tags":["cli-id","branch","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"}