{"record":{"id":"16d8949b7b45fa49","repo":"Hmbown/CodeWhale","slug":"bundle-carries-project-entries-import-it-with-project-from","errorCode":null,"errorMessage":"bundle carries [project] entries; import it with --project from the workspace instead","messagePattern":"bundle carries \\[project\\] entries; import it with --project from the workspace instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":1146,"sourceCode":"    }\n\n    match std::fs::remove_file(target) {\n        Ok(()) => Ok(()),\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),\n        Err(error) => Err(error)\n            .with_context(|| format!(\"removing newly-created config {}\", target.display())),\n    }\n}\n\n/// Build the exact candidate used for both preview and commit. Legacy route\n/// migration remains in memory until the existing ConfigStore CAS save.\nfn prepare_import(\n    bundle: &PortableBundle,\n    store: &codewhale_config::ConfigStore,\n    scope: BundleScope,\n) -> Result<PreparedImport> {\n    match scope {\n        BundleScope::Global if !bundle.project.entries.is_empty() => bail!(\n            \"bundle carries [project] entries; import it with --project from the workspace instead\"\n        ),\n        BundleScope::Project if !bundle.global.entries.is_empty() => bail!(\n            \"bundle carries [global] entries; importing them into a project document would leak machine state\"\n        ),\n        _ => {}\n    }\n    validate_scope_target(scope, store.path())?;\n    let mut plan = plan_import(bundle, &store.config, scope);\n    if !plan.conflicting.is_empty() || (plan.is_no_op() && plan.skipped.is_empty()) {\n        return Ok(PreparedImport {\n            plan,\n            candidate: store.config.clone(),\n        });\n    }\n    let rendered;\n    let original = if let Some(original) = store.original_body() {\n        original","sourceCodeStart":1128,"sourceCodeEnd":1164,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/config_bundles.rs#L1128-L1164","documentation":"prepare_import enforces scope separation: a Global-scope import refuses a bundle that contains [project] entries, directing the user to run the import with --project from inside the workspace. This prevents project-specific configuration from being written into (or silently dropped from) the global document, and the sibling Project-scope check prevents the reverse leak.","triggerScenarios":"Running `codewhale bundle import` (global scope, the default) on a bundle whose TOML contains a non-empty [project] table; prepare_import inspects bundle.project.entries and bails before planning any writes.","commonSituations":"Sharing a bundle exported with both global and project sections and importing it globally; forgetting the --project flag; running the command outside the workspace so project scope wasn't selectable.","solutions":["Re-run the import with --project from within the target workspace so [project] entries land in the project document.","Strip the [project] section from the bundle if you truly only want the global entries.","Split the bundle: export global and project scopes separately and import each into its matching scope.","cd into the workspace root first — project scope imports require being in the workspace."],"exampleFix":"// before\ncodewhale bundle import team.toml\n// after\ncd /path/to/workspace\ncodewhale bundle import team.toml --project","handlingStrategy":"validation","validationCode":"// Check the bundle's scopes before choosing import flags:\n// grep -n '^\\[project\\]' team.toml  # non-empty [project] requires --project\n// grep -n '^\\[global\\]' team.toml   # non-empty [global] conflicts with --project","typeGuard":"fn bundle_matches_scope(b: &PortableBundle, scope: BundleScope) -> bool {\n    match scope {\n        BundleScope::Global => b.project.entries.is_empty(),\n        BundleScope::Project => b.global.entries.is_empty(),\n    }\n}","tryCatchPattern":null,"preventionTips":["Match the import flag to the bundle's sections: [project] needs --project, [global] needs global scope.","cd into the workspace before project-scope imports.","Export global and project bundles separately so each imports into one scope."],"tags":["cli","import","scope","config-bundles"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}