Hmbown/CodeWhale · error

could not prepare imported configuration; contents omitted

Error message

could not prepare imported configuration; contents omitted

What it means

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.

Solutions

  1. Check which bundle entry triggers it by importing entries in smaller batches.
  2. Simplify offending bundle values (avoid exotic types/dates) and re-export the bundle.
  3. Ensure exporter and importer use compatible versions so serialization round-trips.
  4. Report as a bug with the bundle shape (not contents) — merged valid configs should always reparse.
Defensive patterns

Strategy: try-catch

Validate before calling

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}"); }

Try / catch

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, }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/58c5b6ca0008c7c2. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/config_bundles.rs:1207

            }
            if key == "provider" {
                selected_provider = Some(
                    value
                        .as_str()
                        .ok_or_else(|| anyhow!("config entry {dotted:?} must be a string"))?,
                );
                continue;
            }
            collect_model_edits(&dotted, key, value, &mut model_edits)?;
            if codewhale_tui::route_preferences::is_route_key(key) {
                continue;
            }
            apply_config_value(&mut candidate, key, value)?;
        }
    }
    document = toml::to_string(&toml::Value::Table(config_document(&candidate)?))?
        .parse()
        .map_err(|_| anyhow!("could not prepare imported configuration; contents omitted"))?;
    // Definitions precede the exact final selector. Root aliases then target
    // that selected route, so an old provider slot cannot mask an imported model.
    if let Some(provider) = selected_provider {
        codewhale_tui::route_preferences::set_document(
            store.path(),
            &mut document,
            "provider",
            provider,
        )?;
    }
    model_edits.sort_by_key(|(_, key, _)| !key.starts_with("providers."));
    for (_, key, value) in &model_edits {
        codewhale_tui::route_preferences::set_document(store.path(), &mut document, key, value)?;
    }
    let final_value: toml::Value = toml::from_str(&document.to_string())?;
    for (dotted, key, value) in &model_edits {
        let mut replay = document.clone();
        codewhale_tui::route_preferences::set_document(store.path(), &mut replay, key, value)?;

View on GitHub (pinned to 73e0f67d83)