{"record":{"id":"f374347d5fd893a8","repo":"nikivdev/code","slug":"project-mismatch-bundle-is-for-but-this-repo","errorCode":null,"errorMessage":"Project mismatch. Bundle is for '{}' but this repo is '{}'.","messagePattern":"Project mismatch\\. Bundle is for '(.+?)' but this repo is '(.+?)'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/changes.rs","lineNumber":411,"sourceCode":"    trace(&format!(\n        \"reading project name from {}\",\n        flow_path.display()\n    ));\n    let cfg = config::load(&flow_path)\n        .with_context(|| format!(\"failed to read {}\", flow_path.display()))?;\n    let name = cfg\n        .project_name\n        .ok_or_else(|| anyhow::anyhow!(\"flow.toml missing 'name'\"))?;\n    Ok(name)\n}\n\nfn ensure_project_match(repo_root: &Path, bundle: &DiffBundle) -> Result<()> {\n    let bundle_name = bundle.project_name.as_deref().ok_or_else(|| {\n        anyhow::anyhow!(\"Diff bundle missing project name. Recreate with the latest flow.\")\n    })?;\n    let current_name = load_project_name(repo_root)?;\n    if bundle_name != current_name {\n        bail!(\n            \"Project mismatch. Bundle is for '{}' but this repo is '{}'.\",\n            bundle_name,\n            current_name\n        );\n    }\n    trace(&format!(\"project match: {}\", current_name));\n    Ok(())\n}\n\nfn gather_env_vars(keys: &[String]) -> Result<(Option<String>, BTreeMap<String, String>)> {\n    if keys.is_empty() {\n        return Ok((None, BTreeMap::new()));\n    }\n\n    let vars = read_personal_local_env(keys)?;\n    if vars.is_empty() {\n        eprintln!(\"Warning: no matching env vars found in local store.\");\n        return Ok((Some(\"personal\".to_string()), BTreeMap::new()));","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/changes.rs#L393-L429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the bundle was generated from this repo: recreate it with the latest flow (regenerate the bundle in the correct repo).","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.","If you meant to apply the bundle to the other repo, cd into that repo and run the unroll there.","Run with trace/verbose to confirm which project name each side reports before making changes."],"exampleFix":"// before: bundle from 'old-name' applied to repo named 'new-name'\n$ f unroll ~/.flow/bundles/abc.json\nError: Project mismatch. Bundle is for 'old-name' but this repo is 'new-name'.\n// after: fix flow.toml or regenerate the bundle in the right repo\n# flow.toml\nname = \"old-name\"\n$ f unroll ~/.flow/bundles/abc.json  # succeeds","handlingStrategy":"validation","validationCode":"// Rust: before unrolling, verify project name match\nlet cfg = config::load(&repo_root.join(\"flow.toml\"))?;\nlet repo_name = cfg.project_name.expect(\"flow.toml missing 'name'\");\nassert_eq!(bundle.project_name.as_deref(), Some(repo_name.as_str()),\n    \"bundle is for {:?}, repo is {}\", bundle.project_name, repo_name);","typeGuard":"fn bundle_matches_repo(bundle: &DiffBundle, repo_root: &Path) -> bool {\n    bundle.project_name.as_deref()\n        .map(|n| n == load_project_name(repo_root).unwrap_or_default())\n        .unwrap_or(false)\n}","tryCatchPattern":"match unroll_bundle(&repo_root, &bundle_path) {\n    Err(e) if e.to_string().contains(\"Project mismatch\") => {\n        eprintln!(\"Bundle belongs to a different project; regenerate it in this repo.\");\n    }\n    Err(e) => return Err(e),\n    Ok(_) => {}\n}","preventionTips":["Keep flow.toml `name` stable; bump it only when you regenerate all bundles","Store the bundle next to the repo it came from, or embed repo origin in the bundle","Check the bundle's project name (json field project_name) before running unroll"],"tags":["config-mismatch","cli","rust"],"backgroundTag":"project-name-mismatch","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}