Hmbown/CodeWhale · error
imported configuration has an invalid TOML type; contents…
Error message
imported configuration has an invalid TOML type; contents omitted
What it means
config_from_document parses bundle body text into the typed ConfigToml. Any type mismatch between the bundle's TOML values and ConfigToml's field types (serde deserialization error) triggers this message, which deliberately hides the body contents from output. A valid provider selector found in the raw document is then bound to the parsed config.
Solutions
- Fix the offending value types in the bundle so they match the ConfigToml schema.
- Regenerate the bundle by exporting from a working installation of the same version.
- Align exporter/importer versions to eliminate schema drift.
- Validate the bundle body parses as TOML and spot-check field types before importing.
Example fix
// before (bundle body) model_alias_count = "three" // after (bundle body) model_alias_count = 3
Defensive patterns
Strategy: validation
Validate before calling
let body = std::fs::read_to_string(bundle_file)?; let probe: Result<ConfigToml, _> = toml::from_str(&body); if probe.is_err() { eprintln!("bundle does not match current ConfigToml schema"); } Try / catch
match config_from_document(&body) { Err(e) if e.to_string().contains("invalid TOML type") => eprintln!("bundle schema mismatch; regenerate bundle"), other => other, } Prevention
- Generate bundles only via export from a matching version.
- Never hand-edit bundle value types.
- Check version compatibility before importing cross-version bundles.
- Validate the bundle against the schema before applying.
When it happens
Trigger: toml::from_str::<ConfigToml>(body) fails because bundle values do not match the typed schema — e.g. numeric fields given strings, tables where scalars are expected, wrong enum-like values.
Common situations: Bundles produced by newer/older versions with drifted schema, hand-edited bundles with wrong value types, corrupted or truncated bundle files.
Related errors
- Failed to parse configuration; file contents were omitted
- load config store
- active profile is missing or malformed
- Cannot export a non-string default_model without losing its…
- Cannot export a root model alias into a non-table provider…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/d9a5dd44a47c09f5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/config_bundles.rs:1296
edits.push((dotted.to_string(), key.to_string(), value.to_string()));
} else if (key == "providers" || key.starts_with("providers."))
&& let Some(table) = value.as_table()
{
for (child, value) in table {
collect_model_edits(
&format!("{dotted}.{child}"),
&format!("{key}.{child}"),
value,
edits,
)?;
}
}
Ok(())
}
fn config_from_document(body: &str) -> Result<ConfigToml> {
let mut config: ConfigToml = toml::from_str(body).map_err(|_| {
anyhow!("imported configuration has an invalid TOML type; contents omitted")
})?;
let document: toml::Value = toml::from_str(body)?;
if let Some(provider) = document.get("provider").and_then(toml::Value::as_str) {
config.bind_persisted_provider_id(provider)?;
}
Ok(config)
}
fn save_candidate(
candidate: ConfigToml,
store: &mut codewhale_config::ConfigStore,
target_written: &mut bool,
) -> Result<()> {
store.config = candidate;
store.save().context("saving imported bundle")?;
*target_written = true;
Ok(())
}View on GitHub (pinned to 73e0f67d83)