{"record":{"id":"58c5b6ca0008c7c2","repo":"Hmbown/CodeWhale","slug":"could-not-prepare-imported-configuration-contents-omitted","errorCode":null,"errorMessage":"could not prepare imported configuration; contents omitted","messagePattern":"could not prepare imported configuration; contents omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":1207,"sourceCode":"            }\n            if key == \"provider\" {\n                selected_provider = Some(\n                    value\n                        .as_str()\n                        .ok_or_else(|| anyhow!(\"config entry {dotted:?} must be a string\"))?,\n                );\n                continue;\n            }\n            collect_model_edits(&dotted, key, value, &mut model_edits)?;\n            if codewhale_tui::route_preferences::is_route_key(key) {\n                continue;\n            }\n            apply_config_value(&mut candidate, key, value)?;\n        }\n    }\n    document = toml::to_string(&toml::Value::Table(config_document(&candidate)?))?\n        .parse()\n        .map_err(|_| anyhow!(\"could not prepare imported configuration; contents omitted\"))?;\n    // Definitions precede the exact final selector. Root aliases then target\n    // that selected route, so an old provider slot cannot mask an imported model.\n    if let Some(provider) = selected_provider {\n        codewhale_tui::route_preferences::set_document(\n            store.path(),\n            &mut document,\n            \"provider\",\n            provider,\n        )?;\n    }\n    model_edits.sort_by_key(|(_, key, _)| !key.starts_with(\"providers.\"));\n    for (_, key, value) in &model_edits {\n        codewhale_tui::route_preferences::set_document(store.path(), &mut document, key, value)?;\n    }\n    let final_value: toml::Value = toml::from_str(&document.to_string())?;\n    for (dotted, key, value) in &model_edits {\n        let mut replay = document.clone();\n        codewhale_tui::route_preferences::set_document(store.path(), &mut replay, key, value)?;","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/config_bundles.rs#L1189-L1225","documentation":"After applying all bundle entries to the candidate config, prepare_import serializes the merged candidate through config_document and parses the text back into an edit Document. If that final parse fails, the prepared configuration cannot be safely applied, and the message deliberately omits the contents to avoid leaking credentials in output. This is a fail-closed guard on the merged result.","triggerScenarios":"toml::to_string(config_document(&candidate)?) output fails to parse as a Document in prepare_import — i.e., the merged config produced text that is not a valid TOML document.","commonSituations":"A bundle entry that, once merged with the local config, yields TOML text the parser rejects (round-trip/serialization edge case); practically indicates an incompatibility between bundle contents and the current schema or a library bug.","solutions":["Check which bundle entry triggers it by importing entries in smaller batches.","Simplify offending bundle values (avoid exotic types/dates) and re-export the bundle.","Ensure exporter and importer use compatible versions so serialization round-trips.","Report as a bug with the bundle shape (not contents) — merged valid configs should always reparse."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let doc: toml::Value = toml::from_str(&bundle_body)?; for (k, v) in doc.as_table().unwrap() { assert!(v.is_str() || v.is_table() || v.is_integer() || v.is_boolean(), \"unsupported type for {k}\"); }","typeGuard":null,"tryCatchPattern":"match run_import(dry_run = true) { Err(e) if e.to_string().contains(\"could not prepare imported configuration\") => eprintln!(\"merged result unserializable; bisect bundle entries\"), other => other, }","preventionTips":["Dry-run the import first to catch preparation failures without writes.","Import in small batches to isolate the offending entry.","Avoid exotic TOML types (dates, mixed arrays) in bundles.","Keep exporter/importer versions aligned."],"tags":["toml","config","serialization"],"backgroundTag":"toml-parse-error","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}