Hmbown/CodeWhale · error
Failed to update setting: invalid locale
Error message
Failed to update setting: invalid locale '{value}'. Expected: {}. What it means
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.
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.
Example fix
// before
settings.set("locale", "pt-BR")
// after
settings.set("locale", "pt") // use a value from configured_locale_values Defensive patterns
Strategy: validation
Validate before calling
// Validate against the live list before calling set
fn valid_locale(v: &str) -> bool {
codewhale_localization::configured_locale_values(", ")
.split(", ")
.any(|l| l.eq_ignore_ascii_case(v.trim()))
} Try / catch
if let Err(e) = settings.set("locale", value) {
eprintln!("{e}"); // includes current valid locale list
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- api_key cannot be empty string
- approval_policy ' ' is not allowed by requirements ( )
- budget document_kind must be
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/8be39346cba6f7cd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/settings.rs:1629
}
"pin_last_prompt" | "pin_prompt" => {
self.pin_last_prompt = parse_bool(value)?;
}
"show_tool_details" | "tool_details" => {
self.show_tool_details = parse_bool(value)?;
}
"inline_diffs" | "inline_diff" | "diffs" => {
let normalized = value.trim().to_ascii_lowercase();
if !matches!(normalized.as_str(), "full" | "summary" | "off") {
anyhow::bail!(
"Failed to update setting: invalid inline diff mode '{value}'. Expected: full, summary, or off."
);
}
self.inline_diffs = normalized;
}
"locale" | "language" => {
let Some(locale) = normalize_configured_locale(value) else {
anyhow::bail!(
"Failed to update setting: invalid locale '{value}'. Expected: {}.",
codewhale_localization::configured_locale_values(", ")
);
};
self.locale = locale.to_string();
}
"theme" | "ui_theme" => {
self.theme = normalize_theme_setting(value).map_err(anyhow::Error::msg)?;
}
"background_color" | "background" | "bg" => {
self.background_color = normalize_background_color_setting(value)?;
}
"composer_density" | "composer" => {
let normalized = normalize_composer_density(value);
if !["compact", "comfortable", "spacious"].contains(&normalized) {
anyhow::bail!(
"Failed to update setting: invalid composer density '{value}'. Expected: compact, comfortable, spacious."
);View on GitHub (pinned to 73e0f67d83)