{"record":{"id":"f67865df7c2f5fa6","repo":"Hmbown/CodeWhale","slug":"settings-toml-is-malformed-using-defaults-e","errorCode":null,"errorMessage":"⚠ settings.toml is malformed — using defaults ({e})","messagePattern":"⚠ settings\\.toml is malformed — using defaults \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/app/init.rs","lineNumber":157,"sourceCode":"        };\n        // Tideline Startup is the fresh interactive landing surface. It must\n        // not be bypassed by a stale historical `launch_screen = false`, a\n        // provider/config notice, or a previous session record: only an\n        // intentional resume or explicit initial input enters the live session\n        // path directly.\n        let launch_visible = resume_session_id.is_none() && initial_input.is_none();\n        let launch = LaunchState::new(launch_visible, &workspace);\n\n        // If settings.toml exists on disk but couldn't be parsed (we fell back\n        // to defaults), surface a warning in the TUI so the user knows their\n        // file is broken instead of silently losing all settings.\n        let settings_parse_warning = crate::settings::Settings::path().ok().and_then(|p| {\n            if p.exists() {\n                std::fs::read_to_string(&p).ok().and_then(|raw| {\n                    ::toml::from_str::<::toml::Value>(&raw)\n                        .err()\n                        .map(|e| format!(\"⚠ settings.toml is malformed — using defaults ({e})\"))\n                })\n            } else {\n                None\n            }\n        });\n        let provider = config.api_provider();\n        let provider_identity_record =\n            config\n                .active_provider_identity(provider)\n                .unwrap_or_else(|_| {\n                    let key = config.provider_identity_for(provider);\n                    let exact_id = (!(provider == ApiProvider::Custom\n                        && config.uses_legacy_literal_custom_route()))\n                    .then(|| key.clone());\n                    crate::config::ProviderIdentity {\n                        provider,\n                        key,\n                        exact_id,\n                        migrated_legacy_ollama_cloud_route: false,","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/app/init.rs#L139-L175","documentation":"At TUI startup, app init validates settings.toml by parsing it as TOML. If the file exists but cannot be parsed, the app does not abort: it logs this warning and continues with default settings, so user customizations are silently ignored for the session.","triggerScenarios":"The file returned by Settings::path() exists but ::toml::from_str::<Value> fails — e.g. a syntax error (unclosed quote/bracket, stray text) or top-level value not a table.","commonSituations":"Hand-editing settings.toml and leaving a typo; a tool wrote partial/duplicate keys; copy-pasting a snippet with mismatched quotes or brackets; file corrupted by a failed write.","solutions":["Open settings.toml (path shown by Settings::path(), typically $CODEWHALE_HOME/settings.toml or ~/.codewhale/settings.toml) and fix the TOML syntax error — the {e} in the message states the exact line/reason","Validate the file with `tomlcheck settings.toml` or paste it into a TOML linter","If the file is unrecoverable, move it aside (settings.toml.bak) and let the app regenerate defaults, then re-add settings incrementally"],"exampleFix":"// before\nname = \"my theme\nmode = dark\n// after\nname = \"my theme\"\nmode = \"dark\"","handlingStrategy":"validation","validationCode":"// before launch\nlet p = std::path::PathBuf::from(std::env::var(\"CODEWHALE_HOME\").unwrap_or_else(|_| format!(\"{}\", home::home_dir().unwrap().display()))).join(\"settings.toml\");\nif p.exists() {\n    match std::fs::read_to_string(&p).map_err(anyhow::Error::from).and_then(|raw| Ok(toml::from_str::<toml::Value>(&raw)?)) {\n        Ok(_) => {},\n        Err(e) => eprintln!(\"settings.toml invalid: {e:#} — fix before starting\"),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate settings.toml with a TOML linter after every hand edit","Keep settings in version control so a bad edit is easy to diff/revert","Let the app write settings through its UI instead of editing raw TOML"],"tags":["toml","config","startup"],"backgroundTag":"schema-validation-failed","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"}