Hmbown/CodeWhale · error · anyhow::Error

Failed to update setting: invalid ocean treatment '{value}'.

Error message

Failed to update setting: invalid ocean treatment '{value}'. Expected: ombre or flat.

What it means

SettingsStore.update validates appearance values before assigning: ocean_treatment must be one of ombre or flat (compared after trim + ASCII lowercase) (crates/tui/src/settings.rs:1245). Any other string is rejected with this message and the setting is left unchanged.

Source

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

            "tool_collapse" | "tool_collapse_mode" | "collapse" => {
                let normalized = normalize_tool_collapse_mode(value);
                if !matches!(normalized, "compact" | "expanded" | "calm") {
                    return Err(anyhow::anyhow!(
                        "Failed to update setting: invalid tool collapse mode '{value}'. Expected: compact, expanded, or calm."
                    ));
                }
                self.tool_collapse_mode = normalized.to_string();
            }
            "low_motion" | "motion" => {
                self.low_motion = parse_bool(value)?;
            }
            "fancy_animations" | "fancy" | "animations" => {
                self.fancy_animations = parse_bool(value)?;
            }
            "ocean_treatment" | "treatment" | "background_treatment" => {
                let normalized = value.trim().to_ascii_lowercase();
                if !matches!(normalized.as_str(), "ombre" | "flat") {
                    anyhow::bail!(
                        "Failed to update setting: invalid ocean treatment '{value}'. Expected: ombre or flat."
                    );
                }
                self.ocean_treatment = normalized;
            }
            "focus_texture" | "texture" => {
                let normalized = value.trim().to_ascii_lowercase();
                if !matches!(normalized.as_str(), "off" | "scrim" | "grain") {
                    anyhow::bail!(
                        "Failed to update setting: invalid focus texture '{value}'. Expected: off, scrim, or grain."
                    );
                }
                self.focus_texture = normalized;
            }
            "work_surface_placement" | "work_surface" | "work_rail" => {
                let normalized = value.trim().to_ascii_lowercase();
                if !matches!(normalized.as_str(), "top" | "left" | "right" | "off") {
                    anyhow::bail!(

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Use exactly ombre or flat (any casing; it is normalized)
  2. Check the current version's allowed values before writing settings programmatically
  3. Map or drop legacy values during config migration instead of passing them through
  4. If a saved config contains an old value, edit it to a supported one

Example fix

// before
settings.update("treatment", "waves")?; // invalid

// after
settings.update("treatment", "ombre")?;  // or "flat"
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate before updating.
let v = value.trim().to_ascii_lowercase();
if !matches!(v.as_str(), "ombre" | "flat") {
    return Err(anyhow::anyhow!("unsupported ocean treatment"));
}
settings.update("ocean_treatment", &v)?;

Type guard

fn is_valid_ocean_treatment(value: &str) -> bool {
    matches!(value.trim().to_ascii_lowercase().as_str(), "ombre" | "flat")
}

Try / catch

match settings.update("ocean_treatment", value) {
    Ok(()) => {}
    Err(err) if err.to_string().contains("invalid ocean treatment") => {
        settings.update("ocean_treatment", default_ocean_treatment())?;
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: Calling /set treatment wave (or settings.update("ocean_treatment", ...)) with an unsupported value; a config file hand-edited with a removed or renamed option value after an upgrade; scripts passing values from an older version's vocabulary

Common situations: Version upgrades that renamed or removed background treatments; user guessing plausible values; automation copying settings between versions without mapping.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/a17decbc16b2b995. Report an issue: GitHub.