{"record":{"id":"a19fadd2e91900b8","repo":"Hmbown/CodeWhale","slug":"failed-to-update-setting-invalid-key-value-a19fad","errorCode":null,"errorMessage":"Failed to update setting: invalid {key} '{value}'. Expected 0 or a positive integer.","messagePattern":"Failed to update setting: invalid (.+?) '(.+?)'\\. Expected 0 or a positive integer\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":2815,"sourceCode":"        \"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    })\n}\n\nfn parse_u16_range(key: &str, value: &str, min: u16, max: u16) -> Result<u16> {\n    let parsed = value\n        .trim()\n        .parse::<u16>()\n        .map_err(|_| anyhow::anyhow!(\"Invalid {key} '{value}': expected {min}-{max}\"))?;\n    if !(min..=max).contains(&parsed) {\n        anyhow::bail!(\"Invalid {key} '{value}': expected {min}-{max}\");\n    }\n    Ok(parsed)\n}\n\nfn parse_percent_setting(key: &str, value: &str) -> Result<f64> {\n    let trimmed = value.trim().trim_end_matches('%').trim();","sourceCodeStart":2797,"sourceCodeEnd":2833,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L2797-L2833","documentation":"parse_usize_setting: a settings update expected a non-negative integer but the value did not parse as usize; the error names the setting key and offending value so the bad settings command is attributable.","triggerScenarios":"Calling a numeric settings update (e.g. context budget, history size) with a non-integer, negative number, or a value above usize::MAX.","commonSituations":"Entering '-5' for a count; pasting a value with units like '1000ms'; locale-formatted numbers like '1,000'; very large numbers.","solutions":["Provide a plain non-negative integer (e.g. 0, 42)","Remove signs, units, separators, and whitespace beyond trimming","Use a value within usize range for your platform"],"exampleFix":"// before\n/context-budget 1,000\n// after\n/context-budget 1000","handlingStrategy":"validation","validationCode":"fn is_usize_setting(v: &str) -> bool { v.trim().parse::<usize>().is_ok() }","typeGuard":null,"tryCatchPattern":"match parse_usize_setting(key, value) {\n    Ok(n) => /* apply */,\n    Err(e) => eprintln!(\"{e:#}\"),\n}","preventionTips":["Strip units and thousands separators before passing numeric settings","Reject negative numbers in UI input fields","Cap inputs to realistic magnitudes to avoid usize overflow"],"tags":["config","validation","parsing"],"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"}