{"record":{"id":"7abe634facb0fe81","repo":"gitbutlerapp/gitbutler","slug":"no-base-branch-configured","errorCode":null,"errorMessage":"No base branch configured","messagePattern":"No base branch configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/land/mod.rs","lineNumber":192,"sourceCode":"pub fn branch_land(\n    ctx: &mut Context,\n    branch: String,\n    no_ff: bool,\n    whole_stack: bool,\n) -> anyhow::Result<BranchLandResult> {\n    let base_branch = {\n        let mut guard = ctx.exclusive_worktree_access();\n        {\n            let (_repo, ws, _db) = ctx.workspace_and_db_with_perm(guard.read_permission())?;\n            if !ws.kind.has_managed_ref() {\n                bail!(\n                    \"`but land` requires an active GitButler workspace (`gitbutler/workspace`). \\\n                     Switch into the workspace and try again.\"\n                );\n            }\n        }\n        crate::legacy::virtual_branches::get_base_branch_data(ctx, guard.write_permission())?\n            .ok_or_else(|| anyhow::anyhow!(\"No base branch configured\"))?\n    };\n\n    let target_branch_name = base_branch.short_name.clone();\n    if target_branch_name.is_empty() {\n        bail!(\"Configured target branch has no branch name\");\n    }\n    let fetch_remote_name = base_branch.remote_name.clone();\n    let push_remote_name = if base_branch.push_remote_name.is_empty() {\n        fetch_remote_name.clone()\n    } else {\n        base_branch.push_remote_name.clone()\n    };\n    if push_remote_name.is_empty() {\n        bail!(\"Configured target branch has no push remote\");\n    }\n\n    // Triangular remotes (fetch remote != push remote) are out of scope for now: the post-land\n    // reconcile reads the fetch remote's tracking ref, so a push to a different remote would not","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/land/mod.rs#L174-L210","documentation":"branch_land first requires a managed GitButler workspace (gitbutler/workspace ref), then reads the configured base branch via legacy get_base_branch_data. When that returns None — a managed workspace exists but no target/base branch is configured in project metadata — the land aborts with this error before touching any refs.","triggerScenarios":"branch_land on a project whose workspace ref exists but whose base-branch data is absent: onboarding interrupted before target selection, metadata cleared or lost, or partially migrated/restored projects.","commonSituations":"Workspace created but the 'set target branch' step skipped; project restored from backup without metadata; users deliberately clearing the target then running land.","solutions":["Set the target (base) branch in the GitButler app for the project, then retry land.","Programmatically call the set-base-branch flow (e.g. gitbutler_branch_actions::set_base_branch) with refs/remotes/<remote>/<branch> before landing.","Verify with `but status` that a target branch is reported before invoking land."],"exampleFix":"// before\nbut_api::branch_land(ctx, branch, no_ff, whole_stack)?;\n\n// after\nlet target: gitbutler_reference::RemoteRefname = \"refs/remotes/origin/main\".to_string().parse()?;\ngitbutler_branch_actions::set_base_branch(ctx, &target, perm)?;\nbut_api::branch_land(ctx, branch, no_ff, whole_stack)?;","handlingStrategy":"validation","validationCode":"// land preflight:\nlet has_base = crate::legacy::virtual_branches::get_base_branch_data(\n    ctx,\n    perm.read_permission(),\n)?.is_some();\nanyhow::ensure!(has_base, \"configure a target branch before landing\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Complete onboarding (target selection) before exposing land actions.","Include base-branch presence in preflight checks for any land flow.","After restoring projects, verify target metadata before operations."],"tags":["land","target-branch","base-branch","project-configuration"],"backgroundTag":"missing-target-branch-config","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}