Hmbown/CodeWhale · error · anyhow::Error
invalid locale '{value}'
Error message
invalid locale '{value}' What it means
Thrown by UiLocaleValue::from_setting when normalize_configured_locale returns None: after trim/case normalization the string could not be parsed as any locale at all. Note that empty and "auto"/"system" normalize to Some("auto"), so this arm means a genuinely unrecognized value, not a blank one.
Source
Thrown at crates/tui/src/config_ui.rs:1087
match normalize_configured_locale(value) {
Some("auto") => Ok(Self::Auto),
Some("en") => Ok(Self::En),
Some("ja") => Ok(Self::Ja),
Some("zh-Hans") => Ok(Self::ZhHans),
Some("zh-Hant") => Ok(Self::ZhHant),
Some("pt-BR") => Ok(Self::PtBr),
Some("es-419") => Ok(Self::Es419),
Some("vi") => Ok(Self::Vi),
Some("ko") => Ok(Self::Ko),
Some("ca") => Ok(Self::Ca),
Some("de") => Ok(Self::De),
Some("fr") => Ok(Self::Fr),
Some("id") => Ok(Self::Id),
Some("hi") => Ok(Self::Hi),
Some("ru") => Ok(Self::Ru),
Some("uk") => Ok(Self::Uk),
Some(other) => bail!("unsupported locale '{other}'"),
None => bail!("invalid locale '{value}'"),
}
}
}
impl UiThemeValue {
fn as_setting(self) -> &'static str {
match self {
Self::System => "system",
Self::Dark => "dark",
Self::Light => "light",
Self::Grayscale => "grayscale",
Self::CatppuccinMocha => "catppuccin-mocha",
Self::TokyoNight => "tokyo-night",
Self::Dracula => "dracula",
Self::GruvboxDark => "gruvbox-dark",
Self::Matrix => "matrix",
Self::Uwu => "uwu",
Self::Custom => "custom",View on GitHub (pinned to 0c42157ee5)
Solutions
- Correct the value to a supported tag (auto, en, ja, zh-Hans, zh-Hant, pt-BR, es-419, vi, ko, ca, de, fr, id, hi, ru, uk)
- Check for typos, stray whitespace/quotes, or shell-format locale names in the config file
- Use "auto" to let Codewhale detect the locale from the environment
Example fix
# before locale = "english" # after locale = "en"
Defensive patterns
Strategy: validation
Validate before calling
fn parse_locale_or_auto(value: &str) -> Result<UiLocaleValue> {
UiLocaleValue::from_setting(value).with_context(|| {
format!(
"locale '{value}' is not recognized; expected one of {}",
crate::localization::configured_locale_values(", ")
)
})
} Type guard
fn is_valid_locale(value: &str) -> bool {
crate::localization::normalize_configured_locale(value).is_some()
} Prevention
- Never write raw environment locale names (LC_ALL style) into the setting; map them to supported tags first
- Validate config values in one place at load time so the error carries the file and key context
- Default to "auto" when a locale value is missing instead of inventing one
When it happens
Trigger: Setting the locale config value to a string parse_locale cannot map, e.g. "klingon", "123", or a malformed tag like "e__n". Reached via from_setting on any config load or settings change.
Common situations: Hand-editing the config file with a typo; copying a locale name from another tool's format that Codewhale does not accept; scripts writing LC_ALL-style values ("en_US.UTF-8") into the locale setting.
Related errors
- unsupported locale '{other}'
- invalid theme '{value}'
- Invalid cost_currency '{other}': expected usd, cny, rmb, or
- unsupported theme '{other}'
- DS4 /v1/models at {} did not list configured alias '{configu
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/98d5559b37a79af6.
Report an issue: GitHub.