Hmbown/CodeWhale · error
Could not parse destination route identity; contents omitted
Error message
Could not parse destination route identity; contents omitted
What it means
After validating the model string, set_provider_model_document deserializes the destination document into Config to resolve the route identity for provider_identity via resolve_provider_pin_identity. If the document cannot be parsed as Config, it throws this error with contents omitted (the file may contain private text), aborting the model write.
Solutions
- Fix the config document's TOML syntax and field types so it deserializes as Config
- Restore a backup or regenerate the config, then retry the model selection
- Use toml::from_str::<Config> on the file locally to identify which keys break parsing and remove/migrate them
Example fix
# before (config.toml) [providers.openai] context_window = "big" # string, u32 expected # after [providers.openai] context_window = 128000
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight parse of the destination document let cfg: Config = toml::from_str(&doc.to_string())?;
Try / catch
match set_provider_model(doc, provider, identity, model) {
Err(e) if e.to_string().contains("Could not parse destination route identity") => {
eprintln!("config document corrupt; restore before changing model");
}
other => other?,
} Prevention
- Validate the config document parses before any write mutation
- Back up config.toml before edits/upgrades
- Fix schema drift keys as soon as a load warning appears
When it happens
Trigger: Calling persist_provider_selection, persist_provider_model_key, migrate_legacy_route_preferences, or reconcile_root_model_aliases when the target config document contains TOML that fails Config deserialization (bad syntax, wrong-typed fields, unknown schema).
Common situations: Corrupted or hand-edited config.toml; schema drift after upgrading Codewhale; a partially written document from a previous failed save.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- Could not parse configuration for route preference…
- failed to parse config at
- failed to parse config at
- failed to parse config at
- Failed to parse config file
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/64ce290960d37480.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config_persistence.rs:168
model,
)?;
}
}
set_document_value(doc, &["route_preferences_version"], 1_i64)
}
pub(crate) fn set_provider_model_document(
doc: &mut toml_edit::DocumentMut,
provider: ApiProvider,
provider_identity: &str,
model: &str,
) -> anyhow::Result<()> {
anyhow::ensure!(
!model.trim().is_empty() && !model.chars().any(char::is_control),
"model must be nonempty and contain no control characters"
);
let config: crate::config::Config = toml::from_str(&doc.to_string()).map_err(|_| {
anyhow::anyhow!("Could not parse destination route identity; contents omitted")
})?;
let identity = config
.resolve_provider_pin_identity(provider_identity)
.map_err(anyhow::Error::msg)?;
anyhow::ensure!(
identity.provider == provider,
"The destination config has a different provider identity"
);
let provider_key = if provider == ApiProvider::Custom {
if identity.persisted_id().is_none() {
return set_document_value(doc, &["default_text_model"], model);
}
identity.key
} else if identity.migrated_legacy_ollama_cloud_route {
"ollama".to_string()
} else if provider == ApiProvider::DeepseekCN {
"deepseek_cn".to_string()
} else {View on GitHub (pinned to 73e0f67d83)