{"record":{"id":"d4186b223c41f52b","repo":"gitbutlerapp/gitbutler","slug":"branch-is-not-part-of-the-current-workspace","errorCode":null,"errorMessage":"Branch `{}` is not part of the current workspace","messagePattern":"Branch `(.+?)` is not part of the current workspace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/forge.rs","lineNumber":2251,"sourceCode":"    match reviewed_ancestors.pop() {\n        Some(nearest_reviewed_ancestor) => Ok(nearest_reviewed_ancestor.branch_name),\n        None => target_short_name(&ctx.project_meta()?, &repo),\n    }\n}\n\n#[derive(Debug)]\nstruct RemoteHead {\n    branch_name: String,\n    remote_tip: gix::ObjectId,\n}\n\nfn lane_chain_for_branch<'a>(\n    info: &'a but_workspace::RefInfo,\n    branch: &gix::refs::FullNameRef,\n) -> Result<Vec<(but_workspace::ref_info::Lane<'a>, usize)>> {\n    let chain = info.lane_chain(branch);\n    if chain.is_empty() {\n        anyhow::bail!(\n            \"Branch `{}` is not part of the current workspace\",\n            branch.shorten()\n        );\n    }\n    Ok(chain)\n}\n\n/// The numbers of reviews the forge cache currently knows as open.\n///\n/// The mutation flows gate on this: only an open review is a valid target for\n/// retargeting, footer syncs, creation targets, or merge selection. A\n/// segment's metadata number can also be settled display state — an\n/// integrated branch's landed identity, or a merge still awaiting\n/// integration detection — which must never reach the forge as a mutation.\npub fn open_review_numbers(ctx: &Context) -> Result<std::collections::HashSet<i64>> {\n    let db = ctx.db.get_cache()?;\n    Ok(but_forge::cached_review_states(&db)?\n        .into_iter()","sourceCodeStart":2233,"sourceCodeEnd":2269,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/legacy/forge.rs#L2233-L2269","documentation":"lane_chain_for_branch resolves a branch to its lane chain within the workspace RefInfo. If info.lane_chain() returns an empty chain, the branch is not part of the current workspace, and this error is thrown with the branch name.","triggerScenarios":"Creating a review for a branch that exists in the repo but is not included in any workspace lane (not applied/managed by the workspace).","commonSituations":"Selecting a stale or archived branch for review; branch was unapplied from the workspace; typos or refs from outside the workspace being passed to review creation.","solutions":["Apply the branch to the workspace (e.g. `but branch apply` / workspace UI) before creating a review","Verify the branch name/ref is correct and currently applied","Create the review from a branch that is part of the workspace"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const applied = await getWorkspaceBranches(projectId);\nif (!applied.some(b => b.ref === branchRef)) {\n  await applyBranchToWorkspace(projectId, branchRef);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createReview(projectId, branchRef);\n} catch (e) {\n  if (String(e).includes('not part of the current workspace')) {\n    await applyBranchToWorkspace(projectId, branchRef);\n    await createReview(projectId, branchRef);\n  } else throw e;\n}","preventionTips":["Only create reviews from branches applied to the workspace","Verify the branch ref name is correct","Re-apply unapplied/archived branches before review"],"tags":["rust","forge","workspace"],"backgroundTag":"resource-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"}