Hmbown/CodeWhale · error

Failed to update setting: invalid sandbox_mode

Error message

Failed to update setting: invalid sandbox_mode '{value}'. Expected: read-only, workspace-write, danger-full-access, or external-sandbox.

What it means

The sandbox_mode setting (aliases `sandbox`, `filesystem_sandbox`) must normalize to one of read-only, workspace-write, danger-full-access, or external-sandbox; otherwise normalize_sandbox_mode returns None and the arm bails. This mirrors the Codex-style sandbox vocabulary and gates filesystem access, so unknown values are rejected.

Solutions

  1. Use one of: read-only, workspace-write, danger-full-access, external-sandbox (check normalize_sandbox_mode for aliases).
  2. Match the hyphenated spelling exactly; underscores are not accepted unless the normalizer maps them.
  3. Choose the least privileged mode that works (read-only or workspace-write) instead of danger-full-access.

Example fix

// before
settings.set("sandbox", "workspace_write")?;
// after
settings.set("sandbox", "workspace-write")?;
Defensive patterns

Strategy: validation

Validate before calling

const SANDBOX_MODES: [&str; 4] = ["read-only", "workspace-write", "danger-full-access", "external-sandbox"];
if !SANDBOX_MODES.contains(&value.trim().to_ascii_lowercase().as_str()) {
    return Err(format!("sandbox_mode must be one of {SANDBOX_MODES:?}"));
}
settings.set("sandbox_mode", value)?;

Type guard

fn is_valid_sandbox(v: &str) -> bool {
    matches!(v.trim().to_ascii_lowercase().as_str(),
        "read-only" | "workspace-write" | "danger-full-access" | "external-sandbox")
}

Try / catch

match settings.set("sandbox", value) {
    Ok(()) => {}
    Err(e) if e.to_string().contains("invalid sandbox_mode") => {
        eprintln!("{e}; using 'workspace-write'");
        settings.set("sandbox", "workspace-write")?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling Settings::set("sandbox_mode", v) (or aliases) or /config sandbox <v> with values like 'none', 'strict', 'workspace', or underscore forms such as 'workspace_write'.

Common situations: Configs copied from Codex/other tools using 'danger-full-access' variants with different spelling; users writing 'read_only' with an underscore; assuming 'off' disables sandboxing.

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@433685b202 (2026-09-15). Data as JSON: /api/errors/07ff83a45e8007ec. Report an issue: GitHub.

Appendix: source

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

                anyhow::bail!(
                    "Model defaults belong to config.toml. Use /model and choose Remember as my default, or /config model <id> --save."
                );
            }
            "reasoning_effort" | "effort" => {
                self.reasoning_effort = normalize_reasoning_effort_setting(value)?;
            }
            "permission_posture" | "permissions" => {
                self.permission_posture = normalize_permission_posture(value);
                if self.permission_posture.is_none() {
                    anyhow::bail!(
                        "Failed to update setting: invalid permission posture '{value}'. Expected: ask, auto-review, or full-access."
                    );
                }
            }
            "sandbox_mode" | "sandbox" | "filesystem_sandbox" => {
                self.sandbox_mode = normalize_sandbox_mode(value);
                if self.sandbox_mode.is_none() {
                    anyhow::bail!(
                        "Failed to update setting: invalid sandbox_mode '{value}'. Expected: read-only, workspace-write, danger-full-access, or external-sandbox."
                    );
                }
            }
            _ => {
                anyhow::bail!("Failed to update setting: unknown setting '{key}'.");
            }
        }
        if let Some(canonical) = canonical {
            self.provenance
                .insert(canonical.to_string(), Layer::SessionOverride);
        }
        Ok(())
    }

    /// Apply a named settings preset (#3478).
    ///
    /// Presets are the first bundled-settings mechanism: a single name applies a

View on GitHub (pinned to 433685b202)