nikivdev/code · error

Project mismatch. Bundle is for '{}' but this repo is '{}'.

Error message

Project mismatch. Bundle is for '{}' but this repo is '{}'.

What it means

Thrown by ensure_project_match (src/changes.rs:411) when unrolling a diff bundle whose embedded project_name differs from the name in the current repo's flow.toml. The check prevents applying a bundle of changes to a repository it was not produced from. The comparison happens after load_project_name successfully reads flow.toml, so the repo config itself is valid.

Source

Thrown at src/changes.rs:411

    trace(&format!(
        "reading project name from {}",
        flow_path.display()
    ));
    let cfg = config::load(&flow_path)
        .with_context(|| format!("failed to read {}", flow_path.display()))?;
    let name = cfg
        .project_name
        .ok_or_else(|| anyhow::anyhow!("flow.toml missing 'name'"))?;
    Ok(name)
}

fn ensure_project_match(repo_root: &Path, bundle: &DiffBundle) -> Result<()> {
    let bundle_name = bundle.project_name.as_deref().ok_or_else(|| {
        anyhow::anyhow!("Diff bundle missing project name. Recreate with the latest flow.")
    })?;
    let current_name = load_project_name(repo_root)?;
    if bundle_name != current_name {
        bail!(
            "Project mismatch. Bundle is for '{}' but this repo is '{}'.",
            bundle_name,
            current_name
        );
    }
    trace(&format!("project match: {}", current_name));
    Ok(())
}

fn gather_env_vars(keys: &[String]) -> Result<(Option<String>, BTreeMap<String, String>)> {
    if keys.is_empty() {
        return Ok((None, BTreeMap::new()));
    }

    let vars = read_personal_local_env(keys)?;
    if vars.is_empty() {
        eprintln!("Warning: no matching env vars found in local store.");
        return Ok((Some("personal".to_string()), BTreeMap::new()));

View on GitHub (pinned to a747e741ae)

Solutions

  1. Verify the bundle was generated from this repo: recreate it with the latest flow (regenerate the bundle in the correct repo).
  2. If the rename in flow.toml was intentional and the bundle should still apply, temporarily set flow.toml `name` back to the bundle's project name, unroll, then restore.
  3. If you meant to apply the bundle to the other repo, cd into that repo and run the unroll there.
  4. Run with trace/verbose to confirm which project name each side reports before making changes.

Example fix

// before: bundle from 'old-name' applied to repo named 'new-name'
$ f unroll ~/.flow/bundles/abc.json
Error: Project mismatch. Bundle is for 'old-name' but this repo is 'new-name'.
// after: fix flow.toml or regenerate the bundle in the right repo
# flow.toml
name = "old-name"
$ f unroll ~/.flow/bundles/abc.json  # succeeds
Defensive patterns

Strategy: validation

Validate before calling

// Rust: before unrolling, verify project name match
let cfg = config::load(&repo_root.join("flow.toml"))?;
let repo_name = cfg.project_name.expect("flow.toml missing 'name'");
assert_eq!(bundle.project_name.as_deref(), Some(repo_name.as_str()),
    "bundle is for {:?}, repo is {}", bundle.project_name, repo_name);

Type guard

fn bundle_matches_repo(bundle: &DiffBundle, repo_root: &Path) -> bool {
    bundle.project_name.as_deref()
        .map(|n| n == load_project_name(repo_root).unwrap_or_default())
        .unwrap_or(false)
}

Try / catch

match unroll_bundle(&repo_root, &bundle_path) {
    Err(e) if e.to_string().contains("Project mismatch") => {
        eprintln!("Bundle belongs to a different project; regenerate it in this repo.");
    }
    Err(e) => return Err(e),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: Calling `f unroll <bundle>` (unroll_bundle -> ensure_project_match) where bundle.project_name != flow.toml's `name`, e.g. applying a bundle exported from a different repo, or after renaming the project in flow.toml since the bundle was created.

Common situations: Sharing bundles between repos/clones that were configured with different project names; editing `name` in flow.toml after generating a bundle; a stale bundle from an old project kept in the bundle directory; copy-pasting a repo and only changing the project name.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/f374347d5fd893a8. Report an issue: GitHub.