Hmbown/CodeWhale · error

Failed to update setting: invalid mention_menu_behavior

Error message

Failed to update setting: invalid mention_menu_behavior '{value}'. Expected: fuzzy, browser.

What it means

normalize_mention_menu_behavior maps user input to one of two canonical values: 'fuzzy' (aliases: default) or 'browser' (aliases: browse, file-browser, file_browser), case-insensitively. Anything else bails with this error listing the accepted values. It validates the mention_menu_behavior setting.

Solutions

  1. Use 'fuzzy' or 'browser' (or their aliases: default, browse, file-browser, file_browser)
  2. Check the current value with the settings display and correct it
  3. If migrating from an older version, remap removed modes to fuzzy or browser

Example fix

// before
set mention_menu_behavior autocomplete
// after
set mention_menu_behavior fuzzy
Defensive patterns

Strategy: validation

Validate before calling

const VALID_MENTION_MODES: [&str; 6] = ["fuzzy","default","browser","browse","file-browser","file_browser"];
fn valid_mention_mode(v: &str) -> bool {
    VALID_MENTION_MODES.contains(&v.trim().to_ascii_lowercase().as_str())
}

Try / catch

match normalize_mention_menu_behavior(raw) {
    Ok(mode) => /* store mode */,
    Err(e) if e.to_string().contains("mention_menu_behavior") => {
        eprintln!("{e}"); // offer a fuzzy/browser picker
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `/setting mention_menu_behavior autocomplete` or any value outside the alias list — including empty strings and misspellings like "fuzze".

Common situations: Guessing a third mode that doesn't exist; older config values from a version with more options; typos when hand-editing settings.toml.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/cb1a7475f2895d93. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/settings.rs:2852

    let percent = trimmed.parse::<f64>().map_err(|_| {
        anyhow::anyhow!(
            "Failed to update setting: invalid {key} '{value}'. Expected a number from 10 to 100."
        )
    })?;
    if !(10.0..=100.0).contains(&percent) {
        anyhow::bail!(
            "Failed to update setting: invalid {key} '{value}'. Expected a number from 10 to 100."
        );
    }
    Ok(percent)
}

fn normalize_mention_menu_behavior(value: &str) -> Result<String> {
    match value.trim().to_ascii_lowercase().as_str() {
        "fuzzy" | "default" => Ok("fuzzy".to_string()),
        "browser" | "browse" | "file-browser" | "file_browser" => Ok("browser".to_string()),
        _ => {
            anyhow::bail!(
                "Failed to update setting: invalid mention_menu_behavior '{value}'. Expected: fuzzy, browser."
            )
        }
    }
}

fn normalize_mode(value: &str) -> &str {
    match value.trim().to_ascii_lowercase().as_str() {
        "edit" => "agent",
        "normal" => "agent",
        "agent" | "act" | "work" => "agent",
        "plan" => "plan",
        // Operate is a first-class startup mode (Hunter 2026-07-24).
        "operate" | "operation" | "ops" => "operate",
        // yolo was mode+permission; keep mode as Act and migrate posture on load.
        "yolo" => "agent",
        _ => value,
    }

View on GitHub (pinned to 73e0f67d83)