Hmbown/CodeWhale · error · anyhow::Error
Unknown sandbox policy
Error message
Unknown sandbox policy: {other} What it means
`parse_sandbox_policy` matches the policy string against known variants (e.g. "workspace-write") and bails for anything unrecognized. It is an enum-by-string parse: only exact known policy names are accepted.
Solutions
- Use one of the supported policy strings, e.g. "workspace-write".
- Check the option's help/docs for the exact accepted names (matching is exact, case-sensitive).
- If a new policy mode is genuinely needed, extend parse_sandbox_policy with a new variant rather than passing an arbitrary string.
Example fix
// before codewhale run --sandbox-policy workspace_Write // after codewhale run --sandbox-policy workspace-write
Defensive patterns
Strategy: validation
Validate before calling
const POLICIES: &[&str] = &["workspace-write" /* plus documented names */];
if !POLICIES.contains(&policy.as_str()) { panic!("unknown sandbox policy: {policy}"); }
Try / catch
match parse_sandbox_policy(input) {
Ok(policy) => apply(policy),
Err(e) => eprintln!("{e:#}; supported: workspace-write"),
}
Prevention
- Copy policy names from the tool's help output, not from other tools' docs.
- Treat policy strings as exact, case-sensitive enum names.
- Centralize policy constants in scripts instead of inlining ad-hoc strings.
When it happens
Trigger: Passing an unrecognized value to the sandbox policy option (e.g. a misspelled or unsupported policy string) so the `other => bail!` arm is hit.
Common situations: Typos like "workpace-write", copy-pasting a policy name from another tool (Docker/AppArmor names), or using a policy that exists in a different tool but not here.
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
- Command failed with exit code
- Command is required
- Command timed out after
- DSH profile must be `web`, `headless`, or
- --input-json must be a JSON object
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/592f2a06d9b32cb6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:10630
writable_root: Vec<PathBuf>,
exclude_tmpdir: bool,
exclude_slash_tmp: bool,
) -> Result<crate::sandbox::SandboxPolicy> {
use crate::sandbox::SandboxPolicy;
match policy {
"danger-full-access" => Ok(SandboxPolicy::DangerFullAccess),
"read-only" => Ok(SandboxPolicy::ReadOnly),
"external-sandbox" => Ok(SandboxPolicy::ExternalSandbox {
network_access: network,
}),
"workspace-write" => Ok(SandboxPolicy::WorkspaceWrite {
writable_roots: writable_root,
network_access: network,
exclude_tmpdir,
exclude_slash_tmp,
}),
other => bail!("Unknown sandbox policy: {other}"),
}
}
/// Screen the interactive TUI starts on.
///
/// `tui.alternate_screen` is the existing knob and keeps its existing
/// vocabulary: `auto`/`always` stay on the alternate screen (the default),
/// while `never` now selects the full-height inline viewport instead of being
/// parsed and ignored. `/inline` and `/fullscreen` move it at runtime.
fn startup_screen_mode(_cli: &Cli, config: &Config) -> ScreenMode {
config
.tui
.as_ref()
.and_then(|tui| tui.alternate_screen.as_deref())
.and_then(ScreenMode::parse)
.unwrap_or_default()
}
View on GitHub (pinned to 73e0f67d83)