{"record":{"id":"457e3f3722bbe5af","repo":"Hmbown/CodeWhale","slug":"settings-toml-invalid-toml","errorCode":null,"errorMessage":"settings.toml: invalid TOML","messagePattern":"settings\\.toml: invalid TOML","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":784,"sourceCode":"        settings.apply_env_overrides();\n        Ok(settings)\n    }\n\n    /// Read archived route preferences from the user-global settings store.\n    ///\n    /// Canonical config migration must not inherit a project config's sibling\n    /// settings or runtime environment overlays, and must not migrate files.\n    pub(crate) fn load_legacy_route_preferences_read_only() -> Result<Self> {\n        let (primary, legacy_home, legacy_config_dir) = settings_path_candidates_for_scope(false);\n        let settings = Self::load_persisted_from_candidates_with_migration(\n            primary,\n            legacy_home,\n            legacy_config_dir,\n            false,\n        )?;\n        // Interactive readers may recover with defaults, but migration must\n        // not commit those defaults as if the archived selection were read.\n        anyhow::ensure!(settings.load_error.is_none(), \"settings.toml: invalid TOML\");\n        Ok(settings)\n    }\n\n    /// Load the normalized values stored on disk without terminal/runtime\n    /// overlays. Configuration editors use this path so a value labelled\n    /// \"saved\" never silently reports a tmux, SSH, or accessibility override.\n    pub(crate) fn load_persisted() -> Result<Self> {\n        with_settings_transaction(SettingsTransaction::load)\n    }\n\n    /// Load persisted values while the caller already holds the settings\n    /// process mutex and adjacent file lock.\n    fn load_persisted_locked() -> Result<Self> {\n        let (primary, legacy_home, legacy_config_dir) = settings_path_candidates();\n        Self::load_persisted_from_candidates(primary, legacy_home, legacy_config_dir)\n    }\n\n    /// Load normalized disk values for a diagnostic without creating a","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L766-L802","documentation":"This load path (used by migration) reads settings.toml and, because migration must not commit fallback defaults as if the archived selections were actually read, it hard-fails via ensure! when the parsed settings carry a load_error — i.e. the TOML on disk failed to parse. Interactive loads may fall back to defaults, but this stricter path refuses so corrupt settings are never silently persisted.","triggerScenarios":"Migrating or programmatically loading a settings.toml that contains syntax errors (unclosed bracket, bad escape, trailing comma in a table, wrong type for a field) such that the TOML parser sets load_error.","commonSituations":"User hand-edited settings.toml and introduced a TOML syntax error; an editor or script wrote non-TOML content; a partially written/corrupted file after a crash or disk-full during save.","solutions":["Validate the file with a TOML parser (e.g. `python -c \"import tomllib; tomllib.load(open('settings.toml','rb'))\"`) and fix the reported syntax error","Restore settings.toml from a backup or delete it so defaults regenerate, then re-enter settings","Re-save the file from the app's /config editor once it parses cleanly"],"exampleFix":"// before: settings.toml has a syntax error\n// model = \"deepseek-chat\n//   (missing closing quote)\n// after: fixed TOML\n// model = \"deepseek-chat\"\nlet settings = Settings::load_for_migration()?; // Ok once TOML parses","handlingStrategy":"try-catch","validationCode":"fn toml_parses(p: &Path) -> bool {\n    std::fs::read_to_string(p).map(|s| s.parse::<toml::Value>().is_ok()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match Settings::load_for_migration() {\n    Ok(s) => s,\n    Err(e) => { eprintln!(\"fix settings.toml before migrating: {e}\"); return; }\n}","preventionTips":["Validate settings.toml with a TOML linter after hand edits","Keep a backup before editing","Never write the file with non-TOML tooling"],"tags":["config","toml","parse-error"],"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"}