{"record":{"id":"d00b821184a4fafc","repo":"Hmbown/CodeWhale","slug":"could-not-parse-route-configuration-contents-omitted","errorCode":null,"errorMessage":"Could not parse route configuration; contents omitted","messagePattern":"Could not parse route configuration; contents omitted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/route_preferences.rs","lineNumber":28,"sourceCode":"use crate::config_persistence as persistence;\n\n/// Whether a config key names a provider or model selection.\npub fn is_route_key(key: &str) -> bool {\n    matches!(\n        key,\n        \"provider\" | \"model\" | \"default_model\" | \"default_text_model\"\n    ) || provider_model_id(key).is_some()\n}\n\nfn provider_model_id(key: &str) -> Option<&str> {\n    key.strip_prefix(\"providers.\")?\n        .strip_suffix(\".model\")\n        .filter(|id| !id.is_empty())\n}\n\nfn parse_config(body: &str) -> Result<Config> {\n    toml::from_str(body)\n        .map_err(|_| anyhow::anyhow!(\"Could not parse route configuration; contents omitted\"))\n}\n\nfn model_identity(config: &Config, key: &str) -> Result<ProviderIdentity> {\n    if key == \"default_model\" {\n        let provider = if config.api_provider() == ApiProvider::DeepseekCN {\n            ApiProvider::DeepseekCN\n        } else {\n            ApiProvider::Deepseek\n        };\n        config.resolve_provider_pin_identity(provider.as_str())\n    } else if let Some(id) = provider_model_id(key) {\n        // Leaf keys name TOML tables, whose canonical spelling can differ\n        // from the public provider selector. Exact custom tables still win.\n        let selector = if config\n            .providers\n            .as_ref()\n            .and_then(|providers| providers.custom_provider_config(id))\n            .is_some()","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/route_preferences.rs#L10-L46","documentation":"parse_config deserializes the route-preferences TOML file with toml::from_str. On any TOML syntax or structure error it raises this message, deliberately omitting the file contents so sensitive route/provider details never leak into logs. Callers like saved_config, prepare_document, and model_slot_for_document all depend on a fully parseable Config.","triggerScenarios":"Reading crates/tui route preferences file (e.g. via saved_config or prepare_document) when the TOML body has a syntax error, an unknown/misspelled key, or a value of the wrong type; also hit by model_slot_for_document, scrub_root_model_aliases_for_export, set_document, and unset whenever the same file fails to deserialize.","commonSituations":"A hand-edited or partially written route preferences file, an older/legacy config with fields no longer matching the Config schema, a truncated file from an interrupted save, or an editor inserting invalid TOML (bad quoting, duplicate keys, tabs).","solutions":["Open the route preferences file and fix the TOML syntax error; toml error positions are omitted here, so validate the file with a TOML linter or `toml::from_str` in a scratch test.","Back up the file, delete it (or restore from backup) and let the app regenerate defaults.","Check for legacy keys from an older version and rename/remove them to match the current Config struct.","Verify the file is not truncated or being written concurrently; retry after the writer finishes."],"exampleFix":"// before (broken TOML in route preferences)\n[route]\nmodel = \"gpt-4o\n\n// after\n[route]\nmodel = \"gpt-4o\"","handlingStrategy":"validation","validationCode":"fn is_parseable_route_config(body: &str) -> bool {\n    body.parse::<toml::Table>().is_ok()\n}","typeGuard":"fn is_valid_toml(body: &str) -> Result<toml::Table, toml::de::Error> {\n    toml::from_str(body)\n}","tryCatchPattern":"match parse_config(&body) {\n    Ok(config) => apply(config),\n    Err(_) => eprintln!(\"route config TOML invalid; restore or fix the file\"),\n}","preventionTips":["Validate route preferences TOML with a linter after every manual edit","Never hand-edit while the app is running; use the app's own set/unset commands","Keep backups before version migrations of config files"],"tags":["toml","config","parsing","rust"],"backgroundTag":"invalid-config-value","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"}