zeroclaw-labs/zeroclaw · error · anyhow::Error

locale ' ' is not in the locales.toml registry; known

Error message

locale '{locale}' is not in the locales.toml registry; known: {}

What it means

Registry-membership check in validated_locale, after the shape check passes. Fires when the locale string is well-formed but does not match any locale registered in locales.toml (available_locales). The error lists the known codes so the caller can correct the input. Choose one of the listed registered locale codes.

Solutions

  1. Choose one of the known locales printed in the error message.
  2. Add the locale to locales.toml registry first if you intend to introduce a new one.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/main.rs:3304 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/10f164c3bfad0e96. Report an issue: GitHub.

Appendix: source

Thrown at src/main.rs:3304

        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(),
        Some(list) => {
            let names: Vec<&str> = list
                .split(',')
                .map(str::trim)
                .filter(|s| !s.is_empty())

View on GitHub (pinned to 88bb9c8533)