{"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":2559,"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":2541,"sourceCodeEnd":2577,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/settings.rs#L2541-L2577","documentation":"Thrown by parse_bool in the TUI settings update path (crates/tui/src/settings.rs). Boolean ':set' values are normalized through a fixed accept-list: on/true/yes/1/enabled map to true and off/false/no/0/disabled map to false, case-insensitively. Any other string bails with this message. Note the message only advertises on/off, true/false, yes/no even though 1/0/enabled/disabled are also accepted.","triggerScenarios":"Running ':set <boolean-key> <value>' with a value outside the accept-list, e.g. ':set streaming enable', ':set streaming 2', ':set streaming y', or ':set streaming toggle'. Any settings-update API that routes string values through parse_bool hits the same guard.","commonSituations":"Users abbreviate flags ('enable' instead of 'enabled', 'y'/'n'), pass numbers other than 0/1, or paste values with stray characters. Scripts that drive settings programmatically assume looser boolean parsing than this strict list allows.","solutions":["Retry with an accepted literal: on, off, true, false, yes, no, 1, 0, enabled, or disabled (case-insensitive).","If you typed 'enable'/'disable', use the past forms 'enabled'/'disabled'.","Confirm the key is actually boolean; numeric and enum keys route through different parsers with their own accepted values.","For wrappers, pre-validate the value against the accept-list before issuing the set command."],"exampleFix":"# before\n:set auto_compact enable\n\n# after\n:set auto_compact enabled","handlingStrategy":"validation","validationCode":"fn is_accepted_bool(v: &str) -> bool {\n    matches!(\n        v.trim().to_lowercase().as_str(),\n        \"on\" | \"true\" | \"yes\" | \"1\" | \"enabled\"\n            | \"off\" | \"false\" | \"no\" | \"0\" | \"disabled\"\n    )\n}\n\nif !is_accepted_bool(&value) {\n    eprintln!(\"'{value}' is not an accepted boolean literal\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"match update_setting(&key, &value) {\n    Err(err) if err.to_string().contains(\"Failed to parse boolean\") => {\n        // show accepted literals, keep the session alive\n    }\n    other => other,\n}","preventionTips":["Normalize boolean input at the input boundary (arg parser, UI prompt) to on/off before it reaches settings.","Keep the accept-list in one constant and reuse it for both validation and error copy.","Show accepted literals in command hints or completions for set commands."],"tags":["settings","boolean","validation","tui","rust","anyhow"],"backgroundTag":"boolean-config-parse-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}