{"record":{"id":"64ce290960d37480","repo":"Hmbown/CodeWhale","slug":"could-not-parse-destination-route-identity-contents-omitted","errorCode":null,"errorMessage":"Could not parse destination route identity; contents omitted","messagePattern":"Could not parse destination route identity; contents omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config_persistence.rs","lineNumber":168,"sourceCode":"                model,\n            )?;\n        }\n    }\n    set_document_value(doc, &[\"route_preferences_version\"], 1_i64)\n}\n\npub(crate) fn set_provider_model_document(\n    doc: &mut toml_edit::DocumentMut,\n    provider: ApiProvider,\n    provider_identity: &str,\n    model: &str,\n) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        !model.trim().is_empty() && !model.chars().any(char::is_control),\n        \"model must be nonempty and contain no control characters\"\n    );\n    let config: crate::config::Config = toml::from_str(&doc.to_string()).map_err(|_| {\n        anyhow::anyhow!(\"Could not parse destination route identity; contents omitted\")\n    })?;\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    let provider_key = if provider == ApiProvider::Custom {\n        if identity.persisted_id().is_none() {\n            return set_document_value(doc, &[\"default_text_model\"], model);\n        }\n        identity.key\n    } else if identity.migrated_legacy_ollama_cloud_route {\n        \"ollama\".to_string()\n    } else if provider == ApiProvider::DeepseekCN {\n        \"deepseek_cn\".to_string()\n    } else {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config_persistence.rs#L150-L186","documentation":"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.","triggerScenarios":"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).","commonSituations":"Corrupted or hand-edited config.toml; schema drift after upgrading Codewhale; a partially written document from a previous failed save.","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"],"exampleFix":"# before (config.toml)\n[providers.openai]\ncontext_window = \"big\"  # string, u32 expected\n# after\n[providers.openai]\ncontext_window = 128000","handlingStrategy":"try-catch","validationCode":"// pre-flight parse of the destination document\nlet cfg: Config = toml::from_str(&doc.to_string())?;","typeGuard":null,"tryCatchPattern":"match set_provider_model(doc, provider, identity, model) {\n    Err(e) if e.to_string().contains(\"Could not parse destination route identity\") => {\n        eprintln!(\"config document corrupt; restore before changing model\");\n    }\n    other => other?,\n}","preventionTips":["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"],"tags":["config","toml","parse-error","route-identity"],"backgroundTag":"json-parse-error","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}