{"record":{"id":"1c5e55ec04da9228","repo":"Hmbown/CodeWhale","slug":"bundle-carries-global-entries-importing-them-into-a-project","errorCode":null,"errorMessage":"bundle carries [global] entries; importing them into a project document would leak machine state","messagePattern":"bundle carries \\[global\\] entries; importing them into a project document would leak machine state","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":1149,"sourceCode":"        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\n    } else {\n        rendered = store.rendered_body()?;\n        &rendered","sourceCodeStart":1131,"sourceCodeEnd":1167,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/config_bundles.rs#L1131-L1167","documentation":"prepare_import refuses to import a bundle whose Project scope carries [global] entries. Importing machine-specific global configuration (providers, credentials, store paths) into a workspace-scoped project document would leak state from one machine into a shared/committed file. The library throws this as a guard before any plan is built or written.","triggerScenarios":"Calling apply_bundle/run_import (or the dry-run path via prepare_import) with scope=BundleScope::Project while bundle.global.entries is non-empty; typically the bundle was exported as Global or contains both sections and the user passed --project.","commonSituations":"Sharing a bundle exported on a personal machine into a team repo; exporting with mixed sections and importing with --project; scripting `config import --project` against a bundle fetched from a remote source that includes [global] entries.","solutions":["Import without --project so the [global] entries land in the global document, as the message suggests.","Edit the bundle file to remove the [global] section (or split it into a separate global bundle) before importing with --project.","Re-export with `config export --portable --project` so only project-scoped entries are in the bundle."],"exampleFix":"// before\ncodewhale config import team-bundle.toml --project\n// after (global entries handled separately)\ncodewhale config import global-part.toml\ncodewhale config import project-part.toml --project","handlingStrategy":"validation","validationCode":"let text = std::fs::read_to_string(&bundle_path)?;\nlet bundle: toml::Table = toml::from_str(&text)?;\nlet has_global = bundle.get(\"global\").map(|t| t.as_table().map(|t| !t.is_empty()).unwrap_or(false)).unwrap_or(false);\nif has_global && args.project { eprintln!(\"bundle has [global] entries; drop --project or split the bundle\"); }\n","typeGuard":"fn importable_as_project(bundle: &Bundle) -> bool { bundle.global.entries.is_empty() }","tryCatchPattern":"match prepare_import(&bundle, &store, BundleScope::Project) {\n    Err(e) if e.to_string().contains(\"leak machine state\") => eprintln!(\"re-run without --project\"),\n    other => other?,\n}","preventionTips":["Export bundles per scope with --project so sections never mix.","Lint bundles for a non-empty [global] table before scripted --project imports.","Never commit bundles containing [global] entries to shared repos."],"tags":["config","import","scope-mismatch","portability"],"backgroundTag":"conflicting-config-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"}