Hmbown/CodeWhale · error · anyhow::Error

Failed to update setting: invalid work surface placement '{v

Error message

Failed to update setting: invalid work surface placement '{value}'. Expected: top, left, right, or off.

What it means

SettingsStore.update validates work_surface_placement against the allowed set top, left, right, off (after trim + lowercase) (crates/tui/src/settings.rs:1263). Values outside that set are rejected with the expected list in the message and nothing is written.

Source

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

                    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!(
                        "Failed to update setting: invalid work surface placement '{value}'. Expected: top, left, right, or off."
                    );
                }
                self.work_surface_placement = normalized;
            }
            "rail_panel" | "rail" => {
                let normalized = value.trim().to_ascii_lowercase();
                if !matches!(
                    normalized.as_str(),
                    "tasks" | "agents" | "context" | "pinned"
                ) {
                    anyhow::bail!(
                        "Failed to update setting: invalid rail panel '{value}'. Expected: tasks, agents, context, or pinned."
                    );
                }
                self.rail_panel = normalized;
                self.rail_panel_explicit = true;
            }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Use one of top, left, right, or off (casing is normalized)
  2. Bind UI controls to the exact allowed strings
  3. Sanitize imported/legacy config by mapping old placement names to supported ones or falling back to the default
  4. Validate settings files at startup after upgrades

Example fix

// before
settings.update("work_surface", "bottom")?; // invalid

// after
settings.update("work_surface", "left")?;  // or "top" / "right" / "off"
Defensive patterns

Strategy: type-guard

Validate before calling

let v = value.trim().to_ascii_lowercase();
if !matches!(v.as_str(), "top" | "left" | "right" | "off") {
    return Err(anyhow::anyhow!("unsupported work surface placement"));
}
settings.update("work_surface_placement", &v)?;

Type guard

fn is_valid_work_surface_placement(value: &str) -> bool {
    matches!(value.trim().to_ascii_lowercase().as_str(), "top" | "left" | "right" | "off")
}

Try / catch

match settings.update("work_surface_placement", value) {
    Ok(()) => {}
    Err(err) if err.to_string().contains("invalid work surface placement") => {
        settings.update("work_surface_placement", "left")?; // safe default
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: /set work_rail bottom or settings.update("work_surface_placement", "bottom"); config files carrying a placement name from an older layout; code building the value from user free-text or an enum that drifted from the runtime's vocabulary

Common situations: Layout options renamed across versions (e.g. a removed 'bottom' placement); users guessing positions; settings sync between different builds.

Related errors


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