{"record":{"id":"a6043df3da6814b7","repo":"Hmbown/CodeWhale","slug":"could-not-parse-destination-route-contents-omitted","errorCode":null,"errorMessage":"Could not parse destination route; contents omitted","messagePattern":"Could not parse destination route; contents omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config_persistence.rs","lineNumber":206,"sourceCode":"            .metadata()\n            .context(\"provider config metadata\")?\n            .provider_config_key()\n            .to_string()\n    };\n    set_document_value(doc, &[\"providers\", &provider_key, \"model\"], model)\n}\n\n/// One persistent owner and atomic write for an explicitly saved route.\npub(crate) fn persist_provider_selection(\n    config_path: Option<&Path>,\n    provider: ApiProvider,\n    provider_identity: &str,\n    model: Option<&str>,\n) -> anyhow::Result<PathBuf> {\n    let path = config_toml_path(config_path)?;\n    mutate_config_document(&path, |doc| {\n        let config: crate::config::Config = toml::from_str(&doc.to_string())\n            .map_err(|_| anyhow::anyhow!(\"Could not parse destination route; contents omitted\"))?;\n        let identity = config\n            .resolve_provider_pin_identity(provider_identity)\n            .map_err(anyhow::Error::msg)?;\n        anyhow::ensure!(\n            identity.provider == provider,\n            \"The destination config has a different provider identity\"\n        );\n        if let Some(model) = model {\n            set_provider_model_document(\n                doc,\n                provider,\n                identity.persisted_id().unwrap_or(&identity.key),\n                model,\n            )?;\n        }\n        set_document_value(\n            doc,\n            &[\"provider\"],","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config_persistence.rs#L188-L224","documentation":"persist_provider_selection parses the destination config.toml into Config before mutating it; if the TOML is not a loadable Config (parse or validation failure) the mutation is aborted with this error, deliberately omitting file contents from the message. It makes route switching atomic: an unloadable config is never partially rewritten.","triggerScenarios":"persist_provider_selection is called while the destination config.toml fails to deserialize into crate::config::Config (wrong types, unknown fields, or values rejected by validation).","commonSituations":"The config file was hand-edited or written by another tool with incompatible fields; a legacy config shape that no longer deserializes; a partially-written config from a previous crash.","solutions":["Open config.toml and fix the TOML syntax/type errors so it parses as Config, then retry the switch.","Restore a known-good backup of config.toml or use the legacy-custom migration path the tests exercise.","Back up the file, trim the offending sections, and re-run persist_provider_selection."],"exampleFix":"# before (config.toml)\ndefault_text_model = 123\n# after\ndefault_text_model = \"claude-sonnet-4\"","handlingStrategy":"validation","validationCode":"let raw = std::fs::read_to_string(&path)?;\nlet cfg: Result<Config, _> = toml::from_str(&raw);\nif cfg.is_err() {\n    eprintln!(\"config.toml is unloadable; fix it before switching routes\");\n}","typeGuard":null,"tryCatchPattern":"match persist_provider_selection(&path, provider, identity, model) {\n    Err(e) if e.to_string().starts_with(\"Could not parse destination route\") => {\n        // surface file health problem to the user; do not overwrite\n    }\n    other => other?,\n}","preventionTips":["Validate config.toml parses after any manual or external edit.","Keep automated backups of config.toml before bulk edits.","Avoid concurrent tools writing config.toml during a provider switch."],"tags":["config","toml","parsing","rust"],"backgroundTag":"config-file-not-found","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"}