{"record":{"id":"8be39346cba6f7cd","repo":"Hmbown/CodeWhale","slug":"failed-to-update-setting-invalid-locale-value","errorCode":null,"errorMessage":"Failed to update setting: invalid locale '{value}'. Expected: {}.","messagePattern":"Failed to update setting: invalid locale '(.+?)'\\. Expected: (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":1629,"sourceCode":"            }\n            \"pin_last_prompt\" | \"pin_prompt\" => {\n                self.pin_last_prompt = parse_bool(value)?;\n            }\n            \"show_tool_details\" | \"tool_details\" => {\n                self.show_tool_details = parse_bool(value)?;\n            }\n            \"inline_diffs\" | \"inline_diff\" | \"diffs\" => {\n                let normalized = value.trim().to_ascii_lowercase();\n                if !matches!(normalized.as_str(), \"full\" | \"summary\" | \"off\") {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid inline diff mode '{value}'. Expected: full, summary, or off.\"\n                    );\n                }\n                self.inline_diffs = normalized;\n            }\n            \"locale\" | \"language\" => {\n                let Some(locale) = normalize_configured_locale(value) else {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid locale '{value}'. Expected: {}.\",\n                        codewhale_localization::configured_locale_values(\", \")\n                    );\n                };\n                self.locale = locale.to_string();\n            }\n            \"theme\" | \"ui_theme\" => {\n                self.theme = normalize_theme_setting(value).map_err(anyhow::Error::msg)?;\n            }\n            \"background_color\" | \"background\" | \"bg\" => {\n                self.background_color = normalize_background_color_setting(value)?;\n            }\n            \"composer_density\" | \"composer\" => {\n                let normalized = normalize_composer_density(value);\n                if ![\"compact\", \"comfortable\", \"spacious\"].contains(&normalized) {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid composer density '{value}'. Expected: compact, comfortable, spacious.\"\n                    );","sourceCodeStart":1611,"sourceCodeEnd":1647,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L1611-L1647","documentation":"The settings setter rejected the value for `locale` (alias `language`) because normalize_configured_locale did not map it to a supported locale. The error interpolates the live list of valid locale values from codewhale_localization::configured_locale_values so the message always matches the current build.","triggerScenarios":"Settings update with key `locale` or `language` and a value not in the configured locale list, e.g. `set locale pt-BR` when only certain locales ship.","commonSituations":"Using a region variant that is not configured; mixing language codes and display names (e.g. `Deutsch` vs `de`); locale strings copied from BCP-47 contexts.","solutions":["Use one of the locale values listed in the error message itself.","Check codewhale_localization::configured_locale_values for the authoritative list.","Use the canonical short form shown there rather than display names or unlisted region variants."],"exampleFix":"// before\nsettings.set(\"locale\", \"pt-BR\")\n// after\nsettings.set(\"locale\", \"pt\")  // use a value from configured_locale_values","handlingStrategy":"validation","validationCode":"// Validate against the live list before calling set\nfn valid_locale(v: &str) -> bool {\n    codewhale_localization::configured_locale_values(\", \")\n        .split(\", \")\n        .any(|l| l.eq_ignore_ascii_case(v.trim()))\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = settings.set(\"locale\", value) {\n    eprintln!(\"{e}\"); // includes current valid locale list\n}","preventionTips":["Use codes from configured_locale_values, not arbitrary BCP-47 tags.","Prefer the canonical short form over display names.","Re-check the locale list when localization support changes between releases."],"tags":["config","i18n","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"}