{"record":{"id":"94944e5ca2ca044f","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-config-from-file-contents-were","errorCode":null,"errorMessage":"Failed to parse config from {}; file contents were omitted","messagePattern":"Failed to parse config from (.+?); file contents were omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":13397,"sourceCode":"        Some(slot) => crate::credentials::store::with_provider_write_lock(slot, || {\n            clear_active_provider_api_key_under_lock(provider)\n        }),\n        None => clear_active_provider_api_key_under_lock(provider),\n    }\n}\n\nfn clear_active_provider_api_key_under_lock(provider: &str) -> Result<()> {\n    let config_path = credential_config_path()\n        .context(\"Failed to resolve config path while clearing API keys.\")?;\n\n    if config_path.exists() {\n        // `custom` is both the legacy root-shaped route id and a valid exact\n        // `[providers.custom]` table key. Inspect the persisted shape before the\n        // mutation so logout clears exactly one credential scope.\n        let persisted = fs::read_to_string(&config_path)\n            .with_context(|| format!(\"Failed to read config from {}\", config_path.display()))?;\n        let persisted_config: Config = toml::from_str(&persisted).map_err(|_| {\n            anyhow::anyhow!(\n                \"Failed to parse config from {}; file contents were omitted\",\n                codewhale_config::quote_os_path(&config_path)\n            )\n        })?;\n        let exact_literal_custom_table = provider == ApiProvider::Custom.as_str()\n            && persisted_config\n                .providers\n                .as_ref()\n                .and_then(|providers| providers.custom_provider_config(provider))\n                .is_some();\n\n        crate::config_persistence::mutate_config_document(&config_path, |doc| {\n            // The root-level api_key is shared by the legacy DeepSeek and released\n            // literal-custom config shapes. Exact named custom ids remain scoped\n            // to their own table.\n            if matches!(\n                provider,\n                value if value == ApiProvider::Deepseek.as_str()","sourceCodeStart":13379,"sourceCodeEnd":13415,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L13379-L13415","documentation":"During logout, the persisted config.toml is re-read and re-parsed to inspect whether `custom` refers to the legacy root-shaped route or a [providers.custom] table, so logout clears exactly the right credential scope. If toml::from_str::<Config> fails, this error is thrown with the OS-quoted path but the file contents deliberately omitted, since the file may contain private text.","triggerScenarios":"Logging out a provider when the on-disk config.toml no longer deserializes into Config — e.g. invalid TOML syntax, unknown/renamed fields, wrong types after a version upgrade, or manual edits.","commonSituations":"Hand-edited config with a typo; config written by an older/newer Codewhale version with different schema; truncated file from a crashed write; stray keys added by another tool.","solutions":["Open the quoted config path and fix the TOML syntax/fields so it parses as Config (run the app or a TOML linter against it)","Restore a known-good backup of config.toml or delete it and let the app regenerate defaults (re-enter credentials afterwards)","Check for schema changes after upgrading Codewhale and migrate/remove obsolete keys"],"exampleFix":"# before (config.toml)\nmodel = \"gpt-5\"\napi_provider = 123  # wrong type\n# after\nmodel = \"gpt-5\"\napi_provider = \"openai\"","handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure the config parses before running logout flows\nlet cfg: Config = toml::from_str(&std::fs::read_to_string(&path)?)?;","typeGuard":null,"tryCatchPattern":"match logout_provider(provider) {\n    Err(e) if e.to_string().contains(\"Failed to parse config from\") => {\n        eprintln!(\"config.toml is corrupt; fix or restore it (path in message)\");\n    }\n    other => other?,\n}","preventionTips":["Never hand-edit config.toml without validating with a TOML parser afterwards","Keep a backup before upgrading or migrating configs","Run the app's config load once after manual edits to catch schema drift early"],"tags":["config","toml","parse-error","logout"],"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"}