{"record":{"id":"efda4d907dc03d16","repo":"BloopAI/vibe-kanban","slug":"missing-target-branch-mapping-for-repo-in-works","errorCode":null,"errorMessage":"Missing target branch mapping for repo {} in workspace {}","messagePattern":"Missing target branch mapping for repo (.+?) in workspace (.+?)","errorType":"exception","errorClass":"ContainerError","httpStatus":null,"severity":"error","filePath":"crates/local-deployment/src/container.rs","lineNumber":183,"sourceCode":"            WorkspaceRepo::find_by_workspace_id(&self.db.pool, workspace_id).await?;\n        if workspace_repos.is_empty() {\n            return Err(ContainerError::Other(anyhow!(\n                \"Workspace has no repositories configured\"\n            )));\n        }\n\n        let repositories =\n            WorkspaceRepo::find_repos_for_workspace(&self.db.pool, workspace_id).await?;\n        let target_branches: HashMap<_, _> = workspace_repos\n            .iter()\n            .map(|wr| (wr.repo_id, wr.target_branch.clone()))\n            .collect();\n\n        let workspace_inputs: Vec<RepoWorkspaceInput> = repositories\n            .iter()\n            .map(|repo| {\n                let target_branch = target_branches.get(&repo.id).cloned().ok_or_else(|| {\n                    ContainerError::Other(anyhow!(\n                        \"Missing target branch mapping for repo {} in workspace {}\",\n                        repo.id,\n                        workspace_id\n                    ))\n                })?;\n                Ok(RepoWorkspaceInput::new(repo.clone(), target_branch))\n            })\n            .collect::<Result<_, ContainerError>>()?;\n\n        Ok((repositories, workspace_inputs))\n    }\n\n    async fn get_child_from_store(&self, id: &Uuid) -> Option<Arc<RwLock<AsyncGroupChild>>> {\n        let map = self.child_store.read().await;\n        map.get(id).cloned()\n    }\n\n    async fn add_child_to_store(&self, id: Uuid, exec: AsyncGroupChild) {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/crates/local-deployment/src/container.rs#L165-L201","documentation":"After loading repos and their target branches, workspace_repo_inputs builds RepoWorkspaceInput values and requires a target branch for every repo. When target_branches (collected from workspace repo mappings) lacks an entry for a repo id, this error is thrown naming the repo and workspace UUIDs. It indicates an internal inconsistency between the repos list and the branch-mapping map.","triggerScenarios":"A repo exists in the repositories list but has no corresponding workspace repo mapping carrying a target branch — e.g. data drift between find_repos_for_workspace results and the target-branch query, or a mapping row with NULL/missing branch info.","commonSituations":"Manual DB edits that removed a branch field; race where a repo was added to the workspace after branches were snapshotted; version-upgrade migration gaps leaving old rows without target branches.","solutions":["Recreate/repair the workspace repo mapping so every repo has a target_branch set.","Re-check the DB: compare repos returned by find_repos_for_workspace against the target_branches query for the workspace_id.","Re-create the workspace with all repos and branches supplied together.","If caused by a migration/upgrade, backfill missing target_branch values for existing workspace_repos rows."],"exampleFix":"// before\nlet target_branch = target_branches.get(&repo.id).cloned().ok_or_else(...)?;\n// after\nlet target_branch = target_branches.get(&repo.id)\n    .cloned()\n    .or_else(|| repo.default_branch.clone()) // fall back to repo default\n    .ok_or_else(...)?;","handlingStrategy":"validation","validationCode":"let repos = WorkspaceRepo::find_repos_for_workspace(&pool, ws_id).await?;\nlet branches = collect_target_branches(&pool, ws_id).await?;\nlet missing: Vec<_> = repos.iter().filter(|r| !branches.contains_key(&r.id)).collect();\nif !missing.is_empty() {\n    return Err(anyhow!(\"repos without target branch: {:?}\", missing));\n}","typeGuard":null,"tryCatchPattern":"match container.create(&req).await {\n    Err(ContainerError::Other(e)) if e.to_string().contains(\"Missing target branch mapping\") => {\n        // repair mappings or recreate workspace\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Always set target_branch when attaching a repo to a workspace.","Backfill target_branch in migrations for legacy rows.","Avoid manual DB edits to workspace_repos.","Add an integrity check comparing repos vs branch mappings on startup."],"tags":["workspace","data-consistency","internal"],"backgroundTag":"inconsistent-data-state","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}