BloopAI/vibe-kanban · error · ContainerError

Missing target branch mapping for repo {} in workspace {}

Error message

Missing target branch mapping for repo {} in workspace {}

What it means

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.

Source

Thrown at crates/local-deployment/src/container.rs:183

            WorkspaceRepo::find_by_workspace_id(&self.db.pool, workspace_id).await?;
        if workspace_repos.is_empty() {
            return Err(ContainerError::Other(anyhow!(
                "Workspace has no repositories configured"
            )));
        }

        let repositories =
            WorkspaceRepo::find_repos_for_workspace(&self.db.pool, workspace_id).await?;
        let target_branches: HashMap<_, _> = workspace_repos
            .iter()
            .map(|wr| (wr.repo_id, wr.target_branch.clone()))
            .collect();

        let workspace_inputs: Vec<RepoWorkspaceInput> = repositories
            .iter()
            .map(|repo| {
                let target_branch = target_branches.get(&repo.id).cloned().ok_or_else(|| {
                    ContainerError::Other(anyhow!(
                        "Missing target branch mapping for repo {} in workspace {}",
                        repo.id,
                        workspace_id
                    ))
                })?;
                Ok(RepoWorkspaceInput::new(repo.clone(), target_branch))
            })
            .collect::<Result<_, ContainerError>>()?;

        Ok((repositories, workspace_inputs))
    }

    async fn get_child_from_store(&self, id: &Uuid) -> Option<Arc<RwLock<AsyncGroupChild>>> {
        let map = self.child_store.read().await;
        map.get(id).cloned()
    }

    async fn add_child_to_store(&self, id: Uuid, exec: AsyncGroupChild) {

View on GitHub (pinned to 4deb7eca8f)

Solutions

  1. Recreate/repair the workspace repo mapping so every repo has a target_branch set.
  2. Re-check the DB: compare repos returned by find_repos_for_workspace against the target_branches query for the workspace_id.
  3. Re-create the workspace with all repos and branches supplied together.
  4. If caused by a migration/upgrade, backfill missing target_branch values for existing workspace_repos rows.

Example fix

// before
let target_branch = target_branches.get(&repo.id).cloned().ok_or_else(...)?;
// after
let target_branch = target_branches.get(&repo.id)
    .cloned()
    .or_else(|| repo.default_branch.clone()) // fall back to repo default
    .ok_or_else(...)?;
Defensive patterns

Strategy: validation

Validate before calling

let repos = WorkspaceRepo::find_repos_for_workspace(&pool, ws_id).await?;
let branches = collect_target_branches(&pool, ws_id).await?;
let missing: Vec<_> = repos.iter().filter(|r| !branches.contains_key(&r.id)).collect();
if !missing.is_empty() {
    return Err(anyhow!("repos without target branch: {:?}", missing));
}

Try / catch

match container.create(&req).await {
    Err(ContainerError::Other(e)) if e.to_string().contains("Missing target branch mapping") => {
        // repair mappings or recreate workspace
        Err(e)
    }
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29). Data as JSON: /api/errors/efda4d907dc03d16. Report an issue: GitHub.