zeroclaw-labs/zeroclaw · error · anyhow::Error
invalid locale code
Error message
invalid locale code '{locale}' What it means
Shape validation in validated_locale (used to validate the locale argument before selecting i18n resources). Fires when the locale string is empty, longer than 16 chars, or contains characters outside ASCII alphanumerics and '-'. This is the first of two checks (the second is registry membership); it guards against malformed input that could never match a catalog locale. Use a well-formed BCP-47-like code such as 'en' or 'zh-CN'.
Solutions
- Use a valid BCP-47 locale code such as `en`, `en-US`, or `zh-CN`.
- List supported locales and pick one from the registry.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/main.rs:3299 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/2f463f1f1eedceb4.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:3299
};
let mut cmd = cmd;
for name in &sub_names {
let child_prefix = format!("{prefix}-{name}");
cmd = cmd.mut_subcommand(name, |sub| apply_cmd_translations(sub, &child_prefix));
}
cmd
}
#[cfg(feature = "agent-runtime")]
fn validated_locale(locale: &str) -> Result<String> {
let ok_shape = !locale.is_empty()
&& locale.len() <= 16
&& locale
.chars()
.all(|c| c.is_ascii_alphanumeric() || c == '-');
if !ok_shape {
bail!("invalid locale code '{locale}'");
}
let known = zeroclaw_runtime::i18n::available_locales();
if !known.iter().any(|o| o.code == locale) {
let codes: Vec<&str> = known.iter().map(|o| o.code.as_str()).collect();
bail!(
"locale '{locale}' is not in the locales.toml registry; known: {}",
codes.join(", ")
);
}
Ok(locale.to_string())
}
#[cfg(feature = "agent-runtime")]
async fn fetch_locales(locale: &str, catalog: Option<&str>) -> Result<()> {
let locale = validated_locale(locale)?;
let selected: Vec<&(&str, &str, &str)> = match catalog {
None => zeroclaw_config::schema::FTL_CATALOGS.iter().collect(),View on GitHub (pinned to 88bb9c8533)