{"record":{"id":"2eb416195f55ffa5","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-boolean-value-expected-on-off","errorCode":null,"errorMessage":"Failed to parse boolean '{value}': expected on/off, true/false, yes/no.","messagePattern":"Failed to parse boolean '(.+?)': expected on/off, true/false, yes/no\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":2800,"sourceCode":"            trimmed.to_ascii_lowercase().as_str(),\n            \"default\" | \"(default)\" | \"config\" | \"configured\" | \"unset\"\n        )\n    {\n        return Ok(None);\n    }\n\n    ReasoningEffort::parse_strict(trimmed)\n        .map(|effort| Some(effort.as_setting().to_string()))\n        .map_err(|err| anyhow::anyhow!(\"Failed to update setting: {err}\"))\n}\n\n/// Parse a boolean value from various formats\nfn parse_bool(value: &str) -> Result<bool> {\n    match value.to_lowercase().as_str() {\n        \"on\" | \"true\" | \"yes\" | \"1\" | \"enabled\" => Ok(true),\n        \"off\" | \"false\" | \"no\" | \"0\" | \"disabled\" => Ok(false),\n        _ => {\n            anyhow::bail!(\"Failed to parse boolean '{value}': expected on/off, true/false, yes/no.\")\n        }\n    }\n}\n\nfn default_thinking_preview_lines() -> usize {\n    2\n}\n\nfn default_true() -> bool {\n    true\n}\n\nfn parse_usize_setting(key: &str, value: &str) -> Result<usize> {\n    value.trim().parse::<usize>().map_err(|_| {\n        anyhow::anyhow!(\n            \"Failed to update setting: invalid {key} '{value}'. Expected 0 or a positive integer.\"\n        )\n    })","sourceCodeStart":2782,"sourceCodeEnd":2818,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L2782-L2818","documentation":"parse_bool accepts a fixed set of truthy/falsy spellings (on/off, true/false, yes/no, 1/0, enabled/disabled, case-insensitive). Any other string fails with this error. It is a user-input validation failure for boolean settings values.","triggerScenarios":"Setting a boolean setting via the settings command/file with a value outside the accepted list, e.g. `/setting some_bool maybe`, `true ` with odd wording like \"enable\" or \"on!\".","commonSituations":"Typing synonyms not in the list (\"enable\", \"y\", \"t\"); copy-pasting values with extra words; script passing an unset variable producing an empty or garbage value.","solutions":["Use one of the accepted values: on/off, true/false, yes/no, 1/0, enabled/disabled (case-insensitive)","Trim surrounding whitespace and remove stray characters from the value","Check the setting name is actually boolean before assigning it"],"exampleFix":"// before\nset foo_bar enable\n// after\nset foo_bar enabled","handlingStrategy":"validation","validationCode":"const BOOLS: [&str; 10] = [\"on\",\"true\",\"yes\",\"1\",\"enabled\",\"off\",\"false\",\"no\",\"0\",\"disabled\"];\nfn valid_bool(v: &str) -> bool { BOOLS.contains(&v.trim().to_lowercase().as_str()) }","typeGuard":null,"tryCatchPattern":"match parse_setting_bool(raw) {\n    Ok(b) => /* use b */,\n    Err(e) if e.to_string().contains(\"Failed to parse boolean\") => {\n        eprintln!(\"{e}; pass on/off, true/false, yes/no, 1/0, enabled/disabled\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Normalize input to lowercase and trim whitespace before passing","Map your app's own truthy words (\"y\", \"t\", \"enable\") to accepted values first","Never pass empty or interpolated-unset variables as boolean settings"],"tags":["parsing","settings","validation"],"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-23T08:17:48.524Z"}