Hmbown/CodeWhale · warning
⚠ settings.toml is malformed — using defaults
Error message
⚠ settings.toml is malformed — using defaults ({e}) What it means
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.
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
Example fix
// before name = "my theme mode = dark // after name = "my theme" mode = "dark"
Defensive patterns
Strategy: validation
Validate before calling
// before launch
let p = std::path::PathBuf::from(std::env::var("CODEWHALE_HOME").unwrap_or_else(|_| format!("{}", home::home_dir().unwrap().display()))).join("settings.toml");
if p.exists() {
match std::fs::read_to_string(&p).map_err(anyhow::Error::from).and_then(|raw| Ok(toml::from_str::<toml::Value>(&raw)?)) {
Ok(_) => {},
Err(e) => eprintln!("settings.toml invalid: {e:#} — fix before starting"),
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- active profile is missing or malformed
- Cannot export a non-string default_model without losing its…
- Cannot export a root model alias into a non-table provider…
- Cannot export default_model into a non-table provider slot
- config entry must be a string
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/f67865df7c2f5fa6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/app/init.rs:157
};
// Tideline Startup is the fresh interactive landing surface. It must
// not be bypassed by a stale historical `launch_screen = false`, a
// provider/config notice, or a previous session record: only an
// intentional resume or explicit initial input enters the live session
// path directly.
let launch_visible = resume_session_id.is_none() && initial_input.is_none();
let launch = LaunchState::new(launch_visible, &workspace);
// If settings.toml exists on disk but couldn't be parsed (we fell back
// to defaults), surface a warning in the TUI so the user knows their
// file is broken instead of silently losing all settings.
let settings_parse_warning = crate::settings::Settings::path().ok().and_then(|p| {
if p.exists() {
std::fs::read_to_string(&p).ok().and_then(|raw| {
::toml::from_str::<::toml::Value>(&raw)
.err()
.map(|e| format!("⚠ settings.toml is malformed — using defaults ({e})"))
})
} else {
None
}
});
let provider = config.api_provider();
let provider_identity_record =
config
.active_provider_identity(provider)
.unwrap_or_else(|_| {
let key = config.provider_identity_for(provider);
let exact_id = (!(provider == ApiProvider::Custom
&& config.uses_legacy_literal_custom_route()))
.then(|| key.clone());
crate::config::ProviderIdentity {
provider,
key,
exact_id,
migrated_legacy_ollama_cloud_route: false,View on GitHub (pinned to 73e0f67d83)