{"record":{"id":"a17decbc16b2b995","repo":"Hmbown/CodeWhale","slug":"failed-to-update-setting-invalid-ocean-treatment","errorCode":null,"errorMessage":"Failed to update setting: invalid ocean treatment '{value}'. Expected: ombre or flat.","messagePattern":"Failed to update setting: invalid ocean treatment '(.+?)'\\. Expected: ombre or flat\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":1245,"sourceCode":"            \"tool_collapse\" | \"tool_collapse_mode\" | \"collapse\" => {\n                let normalized = normalize_tool_collapse_mode(value);\n                if !matches!(normalized, \"compact\" | \"expanded\" | \"calm\") {\n                    return Err(anyhow::anyhow!(\n                        \"Failed to update setting: invalid tool collapse mode '{value}'. Expected: compact, expanded, or calm.\"\n                    ));\n                }\n                self.tool_collapse_mode = normalized.to_string();\n            }\n            \"low_motion\" | \"motion\" => {\n                self.low_motion = parse_bool(value)?;\n            }\n            \"fancy_animations\" | \"fancy\" | \"animations\" => {\n                self.fancy_animations = parse_bool(value)?;\n            }\n            \"ocean_treatment\" | \"treatment\" | \"background_treatment\" => {\n                let normalized = value.trim().to_ascii_lowercase();\n                if !matches!(normalized.as_str(), \"ombre\" | \"flat\") {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid ocean treatment '{value}'. Expected: ombre or flat.\"\n                    );\n                }\n                self.ocean_treatment = normalized;\n            }\n            \"focus_texture\" | \"texture\" => {\n                let normalized = value.trim().to_ascii_lowercase();\n                if !matches!(normalized.as_str(), \"off\" | \"scrim\" | \"grain\") {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid focus texture '{value}'. Expected: off, scrim, or grain.\"\n                    );\n                }\n                self.focus_texture = normalized;\n            }\n            \"work_surface_placement\" | \"work_surface\" | \"work_rail\" => {\n                let normalized = value.trim().to_ascii_lowercase();\n                if !matches!(normalized.as_str(), \"top\" | \"left\" | \"right\" | \"off\") {\n                    anyhow::bail!(","sourceCodeStart":1227,"sourceCodeEnd":1263,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/settings.rs#L1227-L1263","documentation":"SettingsStore.update validates appearance values before assigning: ocean_treatment must be one of ombre or flat (compared after trim + ASCII lowercase) (crates/tui/src/settings.rs:1245). Any other string is rejected with this message and the setting is left unchanged.","triggerScenarios":"Calling /set treatment wave (or settings.update(\"ocean_treatment\", ...)) with an unsupported value; a config file hand-edited with a removed or renamed option value after an upgrade; scripts passing values from an older version's vocabulary","commonSituations":"Version upgrades that renamed or removed background treatments; user guessing plausible values; automation copying settings between versions without mapping.","solutions":["Use exactly ombre or flat (any casing; it is normalized)","Check the current version's allowed values before writing settings programmatically","Map or drop legacy values during config migration instead of passing them through","If a saved config contains an old value, edit it to a supported one"],"exampleFix":"// before\nsettings.update(\"treatment\", \"waves\")?; // invalid\n\n// after\nsettings.update(\"treatment\", \"ombre\")?;  // or \"flat\"","handlingStrategy":"type-guard","validationCode":"// Validate before updating.\nlet v = value.trim().to_ascii_lowercase();\nif !matches!(v.as_str(), \"ombre\" | \"flat\") {\n    return Err(anyhow::anyhow!(\"unsupported ocean treatment\"));\n}\nsettings.update(\"ocean_treatment\", &v)?;","typeGuard":"fn is_valid_ocean_treatment(value: &str) -> bool {\n    matches!(value.trim().to_ascii_lowercase().as_str(), \"ombre\" | \"flat\")\n}","tryCatchPattern":"match settings.update(\"ocean_treatment\", value) {\n    Ok(()) => {}\n    Err(err) if err.to_string().contains(\"invalid ocean treatment\") => {\n        settings.update(\"ocean_treatment\", default_ocean_treatment())?;\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Bind UI controls to a fixed list: ombre, flat","Normalize (trim + lowercase) user input before passing it in","Re-validate imported config files against the current allowed values and reset invalid entries","Re-check the option vocabulary after version upgrades — names change"],"tags":["rust","settings","validation","tui","configuration"],"backgroundTag":"invalid-settings-value","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}